Browse Source

[WIP] PackageManagement.EnvDTE

pull/45/merge
Daniel Grunwald 12 years ago
parent
commit
77a30c4a1a
  1. 13
      src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj
  2. 141
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeAttribute.cs
  3. 61
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeAttribute2.cs
  4. 85
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeAttributeArgument.cs
  5. 37
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeAttributeArguments.cs
  6. 41
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeAttributes.cs
  7. 90
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeClass.cs
  8. 45
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeElement.cs
  9. 65
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeElementsInNamespace.cs
  10. 79
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeElementsList.cs
  11. 14
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeModelContext.cs
  12. 87
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeNamespace.cs
  13. 248
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeType.cs
  14. 28
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeTypeBaseTypes.cs
  15. 46
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeTypeMembers.cs
  16. 9
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeVariable.cs
  17. 2
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/FileCodeModelCodeNamespace.cs
  18. 21
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/FileCodeModelCodeNamespaceMembers.cs
  19. 43
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/IClassExtensions.cs
  20. 5
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/ProjectItem.cs
  21. 8
      src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/TextPoint.cs
  22. 10
      src/AddIns/Misc/PackageManagement/Project/Src/IProjectContentExtensions.cs
  23. 23
      src/Main/Base/Project/Dom/IEntityModel.cs
  24. 19
      src/Main/Base/Project/Dom/INamespaceModel.cs
  25. 38
      src/Main/Base/Project/Dom/ISymbolModel.cs
  26. 4
      src/Main/Base/Project/Dom/ITypeDefinitionModel.cs
  27. 7
      src/Main/Base/Project/Dom/ModelCollectionLinq.cs
  28. 2
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  29. 13
      src/Main/SharpDevelop/Dom/TypeDefinitionModel.cs

13
src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj

@ -92,13 +92,10 @@ @@ -92,13 +92,10 @@
<Compile Include="Src\EnvDTE\CodeAttribute.cs" />
<Compile Include="Src\EnvDTE\CodeAttribute2.cs" />
<Compile Include="Src\EnvDTE\CodeAttributeArgument.cs" />
<Compile Include="Src\EnvDTE\CodeAttributeArguments.cs" />
<Compile Include="Src\EnvDTE\CodeAttributes.cs" />
<Compile Include="Src\EnvDTE\CodeClass.cs" />
<Compile Include="Src\EnvDTE\CodeClass2.cs" />
<Compile Include="Src\EnvDTE\CodeDelegate.cs" />
<Compile Include="Src\EnvDTE\CodeElement.cs" />
<Compile Include="Src\EnvDTE\CodeElementsInNamespace.cs" />
<Compile Include="Src\EnvDTE\CodeElementsList.cs" />
<Compile Include="Src\EnvDTE\CodeFunction.cs" />
<Compile Include="Src\EnvDTE\CodeFunction2.cs" />
@ -106,6 +103,7 @@ @@ -106,6 +103,7 @@
<Compile Include="Src\EnvDTE\CodeGetterOrSetterFunction.cs" />
<Compile Include="Src\EnvDTE\CodeImport.cs" />
<Compile Include="Src\EnvDTE\CodeInterface.cs" />
<Compile Include="Src\EnvDTE\CodeModelContext.cs" />
<Compile Include="Src\EnvDTE\CodeParameter2.cs" />
<Compile Include="Src\EnvDTE\CodeParameters.cs" />
<Compile Include="Src\EnvDTE\CodeModel.cs" />
@ -116,8 +114,6 @@ @@ -116,8 +114,6 @@
<Compile Include="Src\EnvDTE\CodeSetterFunction.cs" />
<Compile Include="Src\EnvDTE\CodeStruct.cs" />
<Compile Include="Src\EnvDTE\CodeType.cs" />
<Compile Include="Src\EnvDTE\CodeTypeBaseTypes.cs" />
<Compile Include="Src\EnvDTE\CodeTypeMembers.cs" />
<Compile Include="Src\EnvDTE\CodeTypeRef.cs" />
<Compile Include="Src\EnvDTE\CodeTypeRef2.cs" />
<Compile Include="Src\EnvDTE\CodeVariable.cs" />
@ -129,10 +125,8 @@ @@ -129,10 +125,8 @@
<Compile Include="Src\EnvDTE\FileCodeModel2.cs" />
<Compile Include="Src\EnvDTE\FileCodeModelCodeElements.cs" />
<Compile Include="Src\EnvDTE\FileCodeModelCodeNamespace.cs" />
<Compile Include="Src\EnvDTE\FileCodeModelCodeNamespaceMembers.cs" />
<Compile Include="Src\EnvDTE\FileProjectItemExtensions.cs" />
<Compile Include="Src\EnvDTE\FileProjectItems.cs" />
<Compile Include="Src\EnvDTE\IClassExtensions.cs" />
<Compile Include="Src\EnvDTE\ImplementedInterfacesOnClass.cs" />
<Compile Include="Src\EnvDTE\IParameterExtensions.cs" />
<Compile Include="Src\EnvDTE\IReturnTypeExtensions.cs" />
@ -500,6 +494,11 @@ @@ -500,6 +494,11 @@
<Name>ICSharpCode.AvalonEdit</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project>
<Name>ICSharpCode.NRefactory.CSharp</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>

141
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeAttribute.cs

@ -1,72 +1,69 @@ @@ -1,72 +1,69 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Linq;
//using ICSharpCode.SharpDevelop.Dom;
//
//namespace ICSharpCode.PackageManagement.EnvDTE
//{
// public class CodeAttribute : CodeElement, global::EnvDTE.CodeAttribute
// {
// IAttribute attribute;
// static readonly string AttributeEndName = "Attribute";
//
// public CodeAttribute()
// {
// }
//
// public CodeAttribute(IAttribute attribute)
// {
// this.attribute = attribute;
// }
//
// public override global::EnvDTE.vsCMElement Kind {
// get { return global::EnvDTE.vsCMElement.vsCMElementAttribute; }
// }
//
// public override string Name {
// get { return GetShortName(); }
// }
//
// string GetShortName()
// {
// return GetShortName(attribute.AttributeType.Name);
// }
//
// string GetShortName(string name)
// {
// if (name.EndsWith(AttributeEndName)) {
// return name.Substring(0, name.Length - AttributeEndName.Length);
// }
// return name;
// }
//
// public virtual string FullName {
// get { return attribute.AttributeType.FullyQualifiedName; }
// }
//
// public virtual string Value {
// get { return GetValue(); }
// set { }
// }
//
// string GetValue()
// {
// return String.Join(", ", GetArgumentValues());
// }
//
// string[] GetArgumentValues()
// {
// return attribute
// .PositionalArguments
// .Select(arg => GetArgumentValue(arg))
// .ToArray();
// }
//
// string GetArgumentValue(object argument)
// {
// return new CodeAttributeArgument(String.Empty, argument).Value;
// }
// }
//}
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Linq;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.PackageManagement.EnvDTE
{
public class CodeAttribute : CodeElement, global::EnvDTE.CodeAttribute
{
protected readonly IAttribute attribute;
const string AttributeEndName = "Attribute";
public CodeAttribute()
{
}
public CodeAttribute(IAttribute attribute)
{
this.attribute = attribute;
}
public override global::EnvDTE.vsCMElement Kind {
get { return global::EnvDTE.vsCMElement.vsCMElementAttribute; }
}
public override string Name {
get { return GetShortName(attribute.AttributeType.Name); }
}
string GetShortName(string name)
{
if (name.EndsWith(AttributeEndName)) {
return name.Substring(0, name.Length - AttributeEndName.Length);
}
return name;
}
public virtual string FullName {
get { return attribute.AttributeType.FullName; }
}
public virtual string Value {
get { return GetValue(); }
set { }
}
string GetValue()
{
return String.Join(", ", GetArgumentValues());
}
string[] GetArgumentValues()
{
return attribute
.PositionalArguments
.Select(arg => GetArgumentValue(arg))
.ToArray();
}
string GetArgumentValue(ResolveResult argument)
{
return new CodeAttributeArgument(String.Empty, argument).Value;
}
}
}

61
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeAttribute2.cs

@ -1,27 +1,34 @@ @@ -1,27 +1,34 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using ICSharpCode.SharpDevelop.Dom;
//
//namespace ICSharpCode.PackageManagement.EnvDTE
//{
// public class CodeAttribute2 : CodeAttribute, global::EnvDTE.CodeAttribute2
// {
// IAttribute attribute;
//
// public CodeAttribute2()
// {
// }
//
// public CodeAttribute2(IAttribute attribute)
// : base(attribute)
// {
// this.attribute = attribute;
// }
//
// public virtual global::EnvDTE.CodeElements Arguments {
// get { return new CodeAttributeArguments(attribute); }
// }
// }
//}
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.PackageManagement.EnvDTE
{
public class CodeAttribute2 : CodeAttribute, global::EnvDTE.CodeAttribute2
{
public CodeAttribute2()
{
}
public CodeAttribute2(IAttribute attribute)
: base(attribute)
{
}
public virtual global::EnvDTE.CodeElements Arguments {
get {
var list = new CodeElementsList<CodeAttributeArgument>();
foreach (var arg in attribute.PositionalArguments) {
list.Add(new CodeAttributeArgument(string.Empty, arg));
}
foreach (var arg in attribute.NamedArguments) {
list.Add(new CodeAttributeArgument(arg.Key.Name, arg.Value));
}
return list;
}
}
}
}

85
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeAttributeArgument.cs

@ -1,39 +1,46 @@ @@ -1,39 +1,46 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//
//namespace ICSharpCode.PackageManagement.EnvDTE
//{
// public class CodeAttributeArgument : CodeElement, global::EnvDTE.CodeAttributeArgument
// {
// string name;
// string value;
//
// public CodeAttributeArgument()
// {
// }
//
// public CodeAttributeArgument(string name, object value)
// {
// this.name = name;
// this.value = GetValue(value);
// }
//
// string GetValue(object value)
// {
// if (value is string) {
// return String.Format("\"{0}\"", value);
// }
// return value.ToString();
// }
//
// public override string Name {
// get { return name; }
// }
//
// public virtual string Value {
// get { return value; }
// }
// }
//}
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.Semantics;
namespace ICSharpCode.PackageManagement.EnvDTE
{
public class CodeAttributeArgument : CodeElement, global::EnvDTE.CodeAttributeArgument
{
string name;
string value;
public CodeAttributeArgument()
{
}
public CodeAttributeArgument(string name, string value)
{
this.name = name;
this.value = value;
}
public CodeAttributeArgument(string name, ResolveResult value)
{
this.name = name;
this.value = GetValue(value);
}
string GetValue(ResolveResult value)
{
var astBuilder = new TypeSystemAstBuilder();
var ast = astBuilder.ConvertConstantValue(value);
return ast.ToString();
}
public override string Name {
get { return name; }
}
public virtual string Value {
get { return value; }
}
}
}

37
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeAttributeArguments.cs

@ -1,37 +0,0 @@ @@ -1,37 +0,0 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;
//using ICSharpCode.SharpDevelop.Dom;
//
//namespace ICSharpCode.PackageManagement.EnvDTE
//{
// public class CodeAttributeArguments : CodeElementsList
// {
// IAttribute attribute;
//
// public CodeAttributeArguments(IAttribute attribute)
// {
// this.attribute = attribute;
// AddCodeElements();
// }
//
// void AddCodeElements()
// {
// foreach (object arg in attribute.PositionalArguments) {
// AddAttributeArgument(String.Empty, arg);
// }
// foreach (KeyValuePair<string, object> namedArg in attribute.NamedArguments) {
// AddAttributeArgument(namedArg.Key, namedArg.Value);
// }
// }
//
// void AddAttributeArgument(string name, object value)
// {
// AddCodeElement(new CodeAttributeArgument(name, value));
// }
// }
//}

41
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeAttributes.cs

@ -1,41 +0,0 @@ @@ -1,41 +0,0 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;
//using ICSharpCode.SharpDevelop.Dom;
//
//namespace ICSharpCode.PackageManagement.EnvDTE
//{
// public class CodeAttributes : CodeElementsList
// {
// public CodeAttributes(IEntity entity)
// : this(entity.Attributes)
// {
// }
//
// public CodeAttributes(IParameter parameter)
// : this(parameter.Attributes)
// {
// }
//
// public CodeAttributes(IEnumerable<IAttribute> attributes)
// {
// AddAttributes(attributes);
// }
//
// void AddAttributes(IEnumerable<IAttribute> attributes)
// {
// foreach (IAttribute attribute in attributes) {
// AddAttribute(attribute);
// }
// }
//
// void AddAttribute(IAttribute attribute)
// {
// AddCodeElement(new CodeAttribute2(attribute));
// }
// }
//}

90
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeClass.cs

@ -1,34 +1,56 @@ @@ -1,34 +1,56 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using ICSharpCode.SharpDevelop.Dom;
//
//namespace ICSharpCode.PackageManagement.EnvDTE
//{
// public class CodeClass : CodeType, global::EnvDTE.CodeClass
// {
// public CodeClass(IProjectContent projectContent, IClass c)
// : base(projectContent, c)
// {
// }
//
// public CodeClass()
// {
// }
//
// public override global::EnvDTE.vsCMElement Kind {
// get { return global::EnvDTE.vsCMElement.vsCMElementClass; }
// }
//
// public virtual global::EnvDTE.CodeElements ImplementedInterfaces {
// get { return new ImplementedInterfacesOnClass(ProjectContent, Class); }
// }
//
// public virtual global::EnvDTE.CodeVariable AddVariable(string name, object type, object Position = null, global::EnvDTE.vsCMAccess Access = global::EnvDTE.vsCMAccess.vsCMAccessPublic, object Location = null)
// {
// var codeGenerator = new ClassCodeGenerator(Class);
// return codeGenerator.AddPublicVariable(name, (string)type);
// }
// }
//}
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Linq;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.PackageManagement.EnvDTE
{
public class CodeClass : CodeType, global::EnvDTE.CodeClass
{
public CodeClass(CodeModelContext context, ITypeDefinitionModel typeModel)
: base(context, typeModel)
{
}
public CodeClass()
{
}
public override global::EnvDTE.vsCMElement Kind {
get { return global::EnvDTE.vsCMElement.vsCMElementClass; }
}
public virtual global::EnvDTE.CodeElements ImplementedInterfaces {
get {
var list = new CodeElementsList<CodeType>();
var td = typeModel.Resolve();
if (td != null) {
foreach (var baseType in td.GetAllBaseTypes().Where(t => t.Kind == TypeKind.Interface)) {
CodeType element = Create(context, baseType);
if (element != null)
list.Add(element);
}
}
return list;
}
}
public virtual global::EnvDTE.CodeVariable AddVariable(string name, object type, object Position = null, global::EnvDTE.vsCMAccess Access = global::EnvDTE.vsCMAccess.vsCMAccessPublic, object Location = null)
{
var fieldTypeName = new FullTypeName((string)type);
var td = typeModel.Resolve();
if (td == null)
return null;
IType fieldType = td.Compilation.FindType(fieldTypeName);
IFieldModel field = typeModel.AddField(Access.ToAccessibility(), fieldType, name);
if (field != null)
return new CodeVariable(context, field);
else
return null;
}
}
}

45
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeElement.cs

@ -11,20 +11,46 @@ namespace ICSharpCode.PackageManagement.EnvDTE @@ -11,20 +11,46 @@ namespace ICSharpCode.PackageManagement.EnvDTE
public class CodeElement : global::EnvDTE.CodeElementBase, global::EnvDTE.CodeElement
{
DTE dte;
IEntityModel entityModel;
protected readonly CodeModelContext context;
readonly ISymbolModel symbolModel;
public CodeElement()
{
}
public CodeElement(IEntityModel entityModel)
public CodeElement(CodeModelContext context, ISymbolModel symbolModel)
{
this.entityModel = entityModel;
this.Language = entityModel.ParentProject.GetCodeModelLanguage();
this.context = context;
this.symbolModel = symbolModel;
if (symbolModel.ParentProject != null)
this.Language = symbolModel.ParentProject.GetCodeModelLanguage();
}
public static CodeElement CreateMember(CodeModelContext context, IMemberModel m)
{
switch (m.SymbolKind) {
case SymbolKind.Field:
// return new CodeVariable(m);
throw new NotImplementedException();
case SymbolKind.Property:
case SymbolKind.Indexer:
// return new CodeProperty2(m);
throw new NotImplementedException();
case SymbolKind.Event:
return null; // events are not supported in EnvDTE?
case SymbolKind.Method:
case SymbolKind.Operator:
case SymbolKind.Constructor:
case SymbolKind.Destructor:
// return new CodeFunction2(m);
throw new NotImplementedException();
default:
throw new NotSupportedException("Invalid value for SymbolKind");
}
}
public virtual string Name {
get { return entityModel.Name; }
get { return symbolModel.Name; }
}
public virtual string Language { get; protected set; }
@ -40,7 +66,14 @@ namespace ICSharpCode.PackageManagement.EnvDTE @@ -40,7 +66,14 @@ namespace ICSharpCode.PackageManagement.EnvDTE
return null;
}
public virtual global::EnvDTE.vsCMInfoLocation InfoLocation { get; protected set; }
public virtual global::EnvDTE.vsCMInfoLocation InfoLocation {
get {
if (symbolModel != null && symbolModel.ParentProject == context)
return global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationProject;
else
return global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationExternal;
}
}
public virtual global::EnvDTE.DTE DTE {
get {

65
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeElementsInNamespace.cs

@ -1,65 +0,0 @@ @@ -1,65 +0,0 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;
//
//using ICSharpCode.SharpDevelop.Dom;
//
//namespace ICSharpCode.PackageManagement.EnvDTE
//{
// public class CodeElementsInNamespace : CodeElementsList
// {
// IProjectContent projectContent;
// NamespaceName namespaceName;
//
// public CodeElementsInNamespace(IProjectContent projectContent, string qualifiedNamespaceName)
// : this(projectContent, new NamespaceName(qualifiedNamespaceName))
// {
// }
//
// public CodeElementsInNamespace(IProjectContent projectContent, NamespaceName namespaceName)
// {
// this.projectContent = projectContent;
// this.namespaceName = namespaceName;
// GetCodeElements();
// }
//
// void GetCodeElements()
// {
// foreach (ICompletionEntry entry in projectContent.GetNamespaceContents(namespaceName.QualifiedName)) {
// AddCodeElement(entry);
// }
// }
//
// void AddCodeElement(ICompletionEntry entry)
// {
// var namespaceEntry = entry as NamespaceEntry;
// var classEntry = entry as IClass;
// if (namespaceEntry != null) {
// AddCodeNamespace(namespaceEntry);
// } else if (classEntry != null) {
// AddCodeClass(classEntry);
// }
// }
//
// void AddCodeNamespace(NamespaceEntry namespaceEntry)
// {
// if (!String.IsNullOrEmpty(namespaceEntry.Name)) {
// NamespaceName childNamespaceName = namespaceName.CreateChildNamespaceName(namespaceEntry.Name);
// AddCodeElement(new CodeNamespace(projectContent, childNamespaceName));
// }
// }
//
// void AddCodeClass(IClass c)
// {
// if (c.ClassType == ClassType.Interface) {
// AddCodeElement(new CodeInterface(projectContent, c));
// } else {
// AddCodeElement(new CodeClass2(projectContent, c));
// }
// }
// }
//}

79
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeElementsList.cs

@ -5,22 +5,20 @@ using System; @@ -5,22 +5,20 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.PackageManagement.EnvDTE
{
public class CodeElementsList : MarshalByRefObject, global::EnvDTE.CodeElements
public class CodeElementsList<T> : MarshalByRefObject, global::EnvDTE.CodeElements, IList<T>
where T : global::EnvDTE.CodeElement
{
List<CodeElement> elements = new List<CodeElement>();
List<T> elements = new List<T>();
public CodeElementsList()
{
}
protected virtual void AddCodeElement(CodeElement element)
{
elements.Add(element);
}
#region EnvDTE.CodeElements implementation
public int Count {
get { return elements.Count; }
}
@ -30,22 +28,79 @@ namespace ICSharpCode.PackageManagement.EnvDTE @@ -30,22 +28,79 @@ namespace ICSharpCode.PackageManagement.EnvDTE
return elements.GetEnumerator();
}
public global::EnvDTE.CodeElement Item(object index)
global::EnvDTE.CodeElement global::EnvDTE.CodeElements.Item(object index)
{
if (index is int) {
return Item((int)index);
return GetItem((int)index);
}
return Item((string)index);
return GetItem((string)index);
}
global::EnvDTE.CodeElement Item(int index)
global::EnvDTE.CodeElement GetItem(int index)
{
return elements[index - 1];
}
global::EnvDTE.CodeElement Item(string name)
global::EnvDTE.CodeElement GetItem(string name)
{
return elements.Single(item => item.Name == name);
}
#endregion
#region IList<T>
public T this[int index] {
get { return elements[index]; }
set { elements[index] = value; }
}
bool ICollection<T>.IsReadOnly {
get { return false; }
}
public int IndexOf(T item)
{
return elements.IndexOf(item);
}
public void Insert(int index, T item)
{
elements.Insert(index, item);
}
public void RemoveAt(int index)
{
elements.RemoveAt(index);
}
public void Add(T item)
{
elements.Add(item);
}
public void Clear()
{
elements.Clear();
}
public bool Contains(T item)
{
return elements.Contains(item);
}
public void CopyTo(T[] array, int arrayIndex)
{
elements.CopyTo(array, arrayIndex);
}
public bool Remove(T item)
{
return elements.Remove(item);
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return elements.GetEnumerator();
}
#endregion
}
}

14
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeModelContext.cs

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.PackageManagement.EnvDTE
{
public class CodeModelContext
{
public IProject CurrentProject { get; set; }
public IDocumentLoader DocumentLoader { get; set; }
}
}

87
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeNamespace.cs

@ -1,47 +1,40 @@ @@ -1,47 +1,40 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using ICSharpCode.SharpDevelop.Dom;
//
//namespace ICSharpCode.PackageManagement.EnvDTE
//{
// public class CodeNamespace : CodeElement, global::EnvDTE.CodeNamespace
// {
// NamespaceName namespaceName;
// IProjectContent projectContent;
//
// public CodeNamespace(IProjectContent projectContent, string qualifiedName)
// : this(projectContent, new NamespaceName(qualifiedName))
// {
// }
//
// public CodeNamespace(IProjectContent projectContent, NamespaceName namespaceName)
// {
// this.projectContent = projectContent;
// this.namespaceName = namespaceName;
// this.InfoLocation = global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationExternal;
// this.Language = projectContent.GetCodeModelLanguage();
// }
//
// public override global::EnvDTE.vsCMElement Kind {
// get { return global::EnvDTE.vsCMElement.vsCMElementNamespace; }
// }
//
// internal NamespaceName NamespaceName {
// get { return namespaceName; }
// }
//
// public string FullName {
// get { return namespaceName.QualifiedName; }
// }
//
// public override string Name {
// get { return namespaceName.LastPart; }
// }
//
// public virtual global::EnvDTE.CodeElements Members {
// get { return new CodeElementsInNamespace(projectContent, namespaceName); }
// }
// }
//}
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.PackageManagement.EnvDTE
{
public class CodeNamespace : CodeElement, global::EnvDTE.CodeNamespace
{
readonly INamespaceModel model;
public CodeNamespace(CodeModelContext context, INamespaceModel model)
: base(context, model)
{
this.model = model;
}
public override global::EnvDTE.vsCMElement Kind {
get { return global::EnvDTE.vsCMElement.vsCMElementNamespace; }
}
public override global::EnvDTE.vsCMInfoLocation InfoLocation {
get { return global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationExternal; }
}
public string FullName {
get { return model.FullName; }
}
public virtual global::EnvDTE.CodeElements Members {
get {
IModelCollection<CodeElement> namespaceMembers = model.ChildNamespaces.Select(ns => new CodeNamespace(context, ns));
IModelCollection<CodeElement> typeMembers = model.Types.Select(td => CodeType.Create(context, td));
return namespaceMembers.Concat(typeMembers).AsCodeElements();
}
}
}
}

248
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeType.cs

@ -1,91 +1,157 @@ @@ -1,91 +1,157 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Linq;
//using ICSharpCode.SharpDevelop.Dom;
//using ICSharpCode.SharpDevelop.Project;
//
//namespace ICSharpCode.PackageManagement.EnvDTE
//{
// public class CodeType : CodeElement, global::EnvDTE.CodeType
// {
// CodeTypeMembers members;
//
// /// <summary>
// /// Note that projectContent may be different to the IClass.ProjectContent since the class
// /// is retrieved from the namespace contents and could belong to a separate project or
// /// referenced assembly.
// /// </summary>
// public CodeType(IProjectContent projectContent, IClass c)
// : base(c)
// {
// this.Class = c;
// this.ProjectContent = projectContent;
// InfoLocation = GetInfoLocation(projectContent, c);
// }
//
// global::EnvDTE.vsCMInfoLocation GetInfoLocation(IProjectContent projectContent, IClass c)
// {
// if (projectContent.Project == c.ProjectContent.Project) {
// return global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationProject;
// }
// return global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationExternal;
// }
//
// public CodeType()
// {
// }
//
// protected IClass Class { get; private set; }
// protected IProjectContent ProjectContent { get; private set; }
//
// public virtual global::EnvDTE.vsCMAccess Access {
// get { return GetAccess(); }
// set { }
// }
//
// public virtual string FullName {
// get { return Class.FullyQualifiedName; }
// }
//
// public virtual global::EnvDTE.CodeElements Members {
// get {
// if (members == null) {
// members = new CodeTypeMembers(ProjectContent, Class);
// }
// return members;
// }
// }
//
// public virtual global::EnvDTE.CodeElements Bases {
// get { return new CodeTypeBaseTypes(ProjectContent, Class); }
// }
//
// public virtual global::EnvDTE.CodeElements Attributes {
// get { return new CodeAttributes(Class); }
// }
//
// public virtual global::EnvDTE.CodeNamespace Namespace {
// get { return new FileCodeModelCodeNamespace(ProjectContent, Class.Namespace); }
// }
//
// public virtual global::EnvDTE.ProjectItem ProjectItem {
// get {
// if (ProjectContent.Project != null) {
// return new ProjectItem(ProjectContent, Class);
// }
// return null;
// }
// }
//
// /// <summary>
// /// Returns true if the current type matches the fully qualified name or any of its
// /// base types are a match.
// /// </summary>
// protected override bool GetIsDerivedFrom(string fullName)
// {
// return Class.IsDerivedFrom(fullName);
// }
// }
//}
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.PackageManagement.EnvDTE
{
public class CodeType : CodeElement, global::EnvDTE.CodeType
{
protected readonly ITypeDefinitionModel typeModel;
CodeElementsList<CodeElement> members;
public static CodeType Create(CodeModelContext context, IType type)
{
var typeDef = type.GetDefinition();
if (typeDef != null) {
var typeModel = typeDef.GetModel();
if (typeModel != null)
return Create(context, typeModel);
}
return null;
}
public static CodeType Create(CodeModelContext context, ITypeDefinitionModel typeModel)
{
switch (typeModel.TypeKind) {
case TypeKind.Class:
case TypeKind.Module:
goto default;
case TypeKind.Interface:
goto default;
case TypeKind.Struct:
case TypeKind.Void:
goto default;
case TypeKind.Delegate:
goto default;
case TypeKind.Enum:
goto default;
default:
return new CodeType(context, typeModel);
}
}
/// <summary>
/// Note that projectContent may be different to the IClass.ProjectContent since the class
/// is retrieved from the namespace contents and could belong to a separate project or
/// referenced assembly.
/// </summary>
public CodeType(CodeModelContext context, ITypeDefinitionModel typeModel)
: base(context, typeModel)
{
this.typeModel = typeModel;
}
public CodeType()
{
}
public virtual global::EnvDTE.vsCMAccess Access {
get { return typeModel.Accessibility.ToAccess(); }
set { typeModel.Accessibility = value.ToAccessibility(); }
}
public virtual string FullName {
get {
var fullTypeName = typeModel.FullTypeName;
StringBuilder b = new StringBuilder();
if (!string.IsNullOrEmpty(fullTypeName.TopLevelTypeName.Namespace)) {
b.Append(fullTypeName.TopLevelTypeName.Namespace);
b.Append('.');
}
b.Append(fullTypeName.TopLevelTypeName.Name);
for (int i = 0; i < fullTypeName.NestingLevel; i++) {
b.Append('.');
b.Append(fullTypeName.GetNestedTypeName(i));
}
return b.ToString();
}
}
public virtual global::EnvDTE.CodeElements Members {
get {
if (members == null) {
members = typeModel.Members.Select(m => CreateMember(context, m)).AsCodeElements();
}
return members;
}
}
public virtual global::EnvDTE.CodeElements Bases {
get {
var list = new CodeElementsList<CodeType>();
var td = typeModel.Resolve();
if (td != null) {
IEnumerable<IType> baseTypes;
if (td.Kind == TypeKind.Interface)
baseTypes = td.DirectBaseTypes;
else
baseTypes = td.DirectBaseTypes.Where(t => t.Kind != TypeKind.Interface);
foreach (var baseType in baseTypes) {
CodeType element = Create(context, baseType);
if (element != null)
list.Add(element);
}
}
return list;
}
}
public virtual global::EnvDTE.CodeElements Attributes {
get {
var list = new CodeElementsList<CodeAttribute2>();
var td = typeModel.Resolve();
if (td != null) {
foreach (var attr in td.Attributes) {
list.Add(new CodeAttribute2(attr));
}
}
return list;
}
}
public virtual global::EnvDTE.CodeNamespace Namespace {
get {
throw new NotImplementedException();
// return new FileCodeModelCodeNamespace(currentProject, typeModel.Namespace);
}
}
public virtual global::EnvDTE.ProjectItem ProjectItem {
get {
if (context.CurrentProject != null) {
return EnvDTE.ProjectItem.FindByEntity(context.CurrentProject, typeModel);
}
return null;
}
}
/// <summary>
/// Returns true if the current type matches the fully qualified name or any of its
/// base types are a match.
/// </summary>
protected override bool GetIsDerivedFrom(string fullName)
{
var td = typeModel.Resolve();
return td != null && td.GetAllBaseTypeDefinitions().Any(b => b.FullName == fullName);
}
}
}

28
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeTypeBaseTypes.cs

@ -1,28 +0,0 @@ @@ -1,28 +0,0 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using ICSharpCode.SharpDevelop.Dom;
//
//namespace ICSharpCode.PackageManagement.EnvDTE
//{
// public class CodeTypeBaseTypes : CodeElementsList
// {
// IProjectContent projectContent;
// IClass c;
//
// public CodeTypeBaseTypes(IProjectContent projectContent, IClass c)
// {
// this.projectContent = projectContent;
// this.c = c;
// AddBaseTypes();
// }
//
// void AddBaseTypes()
// {
// if (c.BaseType != null) {
// AddCodeElement(CodeClass2.CreateFromBaseType(projectContent, c.BaseType));
// }
// }
// }
//}

46
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeTypeMembers.cs

@ -1,46 +0,0 @@ @@ -1,46 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.PackageManagement.EnvDTE
{
public class CodeTypeMembers : CodeElementsList
{
public CodeTypeMembers(IModelCollection<IMemberModel> members)
{
foreach (var m in members) {
var e = CreateMember(m);
if (e != null)
base.AddCodeElement(e);
}
// TODO track collection changes
//members.CollectionChanged += members_CollectionChanged;
}
CodeElement CreateMember(IMemberModel m)
{
switch (m.SymbolKind) {
case SymbolKind.Field:
// return new CodeVariable(m);
throw new NotImplementedException();
case SymbolKind.Property:
case SymbolKind.Indexer:
// return new CodeProperty2(m);
throw new NotImplementedException();
case SymbolKind.Event:
return null; // events are not supported in EnvDTE?
case SymbolKind.Method:
case SymbolKind.Operator:
case SymbolKind.Constructor:
case SymbolKind.Destructor:
// return new CodeFunction2(m);
throw new NotImplementedException();
default:
throw new NotSupportedException("Invalid value for SymbolKind");
}
}
}
}

9
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/CodeVariable.cs

@ -9,16 +9,15 @@ namespace ICSharpCode.PackageManagement.EnvDTE @@ -9,16 +9,15 @@ namespace ICSharpCode.PackageManagement.EnvDTE
public class CodeVariable : CodeElement, global::EnvDTE.CodeVariable
{
readonly IFieldModel field;
readonly IDocumentLoader documentLoader;
public CodeVariable()
{
}
public CodeVariable(IFieldModel field, IDocumentLoader documentLoader)
public CodeVariable(CodeModelContext context, IFieldModel field)
: base(context, field)
{
this.field = field;
this.documentLoader = documentLoader;
}
public override global::EnvDTE.vsCMElement Kind {
@ -32,12 +31,12 @@ namespace ICSharpCode.PackageManagement.EnvDTE @@ -32,12 +31,12 @@ namespace ICSharpCode.PackageManagement.EnvDTE
public override global::EnvDTE.TextPoint GetStartPoint()
{
return TextPoint.CreateStartPoint(field.Region, documentLoader);
return TextPoint.CreateStartPoint(context, field.Region);
}
public override global::EnvDTE.TextPoint GetEndPoint()
{
return TextPoint.CreateEndPoint(field.Region, documentLoader);
return TextPoint.CreateEndPoint(context, field.Region);
}
}
}

2
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/FileCodeModelCodeNamespace.cs

@ -15,8 +15,6 @@ @@ -15,8 +15,6 @@
// /// </summary>
// public class FileCodeModelCodeNamespace : CodeNamespace
// {
// FileCodeModelCodeNamespaceMembers members = new FileCodeModelCodeNamespaceMembers();
//
// public FileCodeModelCodeNamespace(IProjectContent projectContent, string namespaceName)
// : base(projectContent, namespaceName)
// {

21
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/FileCodeModelCodeNamespaceMembers.cs

@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using ICSharpCode.SharpDevelop.Dom;
//
//namespace ICSharpCode.PackageManagement.EnvDTE
//{
// public class FileCodeModelCodeNamespaceMembers : CodeElementsList
// {
// public FileCodeModelCodeNamespaceMembers()
// {
// }
//
// public void AddClass(IProjectContent projectContent, IClass c)
// {
// var codeClass = new CodeClass2(projectContent, c);
// AddCodeElement(codeClass);
// }
// }
//}

43
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/IClassExtensions.cs

@ -1,43 +0,0 @@ @@ -1,43 +0,0 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System;
//using System.Linq;
//using ICSharpCode.SharpDevelop.Dom;
//
//namespace ICSharpCode.PackageManagement.EnvDTE
//{
// public static class IClassExtensions
// {
// /// <summary>
// /// Returns true if the class fully qualified name matches the name or
// /// any class in the inheritance tree matches the name.
// /// </summary>
// public static bool IsDerivedFrom(this IClass c, string typeName)
// {
// if (c.FullyQualifiedName == typeName) {
// return true;
// }
//
// if (TypeNameMatchesBaseType(c.BaseType, typeName)) {
// return true;
// }
//
// return IsTypeInClassInheritanceTree(c, typeName);
// }
//
// static bool TypeNameMatchesBaseType(IReturnType baseType, string typeName)
// {
// return
// (baseType != null) &&
// (baseType.FullyQualifiedName == typeName);
// }
//
// static bool IsTypeInClassInheritanceTree(IClass c, string typeName)
// {
// return c
// .ClassInheritanceTreeClassesOnly
// .Any(inheritedClass => inheritedClass.FullyQualifiedName == typeName);
// }
// }
//}

5
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/ProjectItem.cs

@ -39,6 +39,11 @@ namespace ICSharpCode.PackageManagement.EnvDTE @@ -39,6 +39,11 @@ namespace ICSharpCode.PackageManagement.EnvDTE
return new FileProjectItems(this);
}
internal static ProjectItem FindByEntity(IProject project, IEntityModel entity)
{
throw new NotImplementedException();
}
// internal ProjectItem(MSBuildBasedProject project, IClass c)
// : this(new Project(project), project.FindFile(c.CompilationUnit.FileName))
// {

8
src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/TextPoint.cs

@ -34,14 +34,14 @@ namespace ICSharpCode.PackageManagement.EnvDTE @@ -34,14 +34,14 @@ namespace ICSharpCode.PackageManagement.EnvDTE
return new EditPoint(fileName, location, documentLoader);
}
internal static TextPoint CreateStartPoint(DomRegion region, IDocumentLoader documentLoader)
internal static TextPoint CreateStartPoint(CodeModelContext context, DomRegion region)
{
return new TextPoint(region.FileName, region.Begin, documentLoader);
return new TextPoint(region.FileName, region.Begin, context.DocumentLoader);
}
internal static TextPoint CreateEndPoint(DomRegion region, IDocumentLoader documentLoader)
internal static TextPoint CreateEndPoint(CodeModelContext context, DomRegion region)
{
return new TextPoint(region.FileName, region.End, documentLoader);
return new TextPoint(region.FileName, region.End, context.DocumentLoader);
}
}
}

10
src/AddIns/Misc/PackageManagement/Project/Src/IProjectContentExtensions.cs

@ -39,5 +39,15 @@ namespace ICSharpCode.PackageManagement @@ -39,5 +39,15 @@ namespace ICSharpCode.PackageManagement
throw new Exception("Invalid value for vsCMAccess");
}
}
public static CodeElementsList<T> AsCodeElements<T>(this IModelCollection<T> input)
where T : global::EnvDTE.CodeElement
{
var list = new CodeElementsList<T>();
// TODO: react to changes
foreach (var element in input)
list.Add(element);
return list;
}
}
}

23
src/Main/Base/Project/Dom/IEntityModel.cs

@ -12,34 +12,13 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -12,34 +12,13 @@ namespace ICSharpCode.SharpDevelop.Dom
/// <summary>
/// An NRefactory entity as a model.
/// </summary>
public interface IEntityModel : INotifyPropertyChanged
public interface IEntityModel : ISymbolModel
{
/// <summary>
/// Gets the name of the entity.
/// </summary>
string Name { get; }
/// <summary>
/// Gets the symbol kind of the entity.
/// </summary>
SymbolKind SymbolKind { get; }
/// <summary>
/// Gets/sets the accessibility of the entity.
/// </summary>
Accessibility Accessibility { get; set; }
/// <summary>
/// Gets the parent project that contains this entity.
/// May return null if the entity is not part of a project.
/// </summary>
IProject ParentProject { get; }
/// <summary>
/// Gets the region where this entity is defined.
/// </summary>
DomRegion Region { get; }
/// <summary>
/// Resolves the entity in the current solution snapshot.
/// Returns null if the entity could not be resolved.

19
src/Main/Base/Project/Dom/INamespaceModel.cs

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// Represents a namespace within a single project.
/// </summary>
public interface INamespaceModel : ISymbolModel
{
string FullName { get; }
INamespaceModel ParentNamespace { get; }
IModelCollection<INamespaceModel> ChildNamespaces { get; }
IModelCollection<ITypeDefinitionModel> Types { get; }
}
}

38
src/Main/Base/Project/Dom/ISymbolModel.cs

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.ComponentModel;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// An NRefactory symbol as a model.
/// </summary>
public interface ISymbolModel : INotifyPropertyChanged
{
/// <summary>
/// Gets the name of the entity.
/// </summary>
string Name { get; }
/// <summary>
/// Gets the symbol kind of the entity.
/// </summary>
SymbolKind SymbolKind { get; }
/// <summary>
/// Gets the parent project that contains this entity.
/// May return null if the entity is not part of a project.
/// </summary>
IProject ParentProject { get; }
/// <summary>
/// Gets the region where this entity is defined.
/// </summary>
DomRegion Region { get; }
}
}

4
src/Main/Base/Project/Dom/ITypeDefinitionModel.cs

@ -13,6 +13,8 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -13,6 +13,8 @@ namespace ICSharpCode.SharpDevelop.Dom
public interface ITypeDefinitionModel : IEntityModel
{
FullTypeName FullTypeName { get; }
string Namespace { get; }
TypeKind TypeKind { get; }
IModelCollection<ITypeDefinitionModel> NestedTypes { get; }
IModelCollection<IMemberModel> Members { get; }
@ -38,5 +40,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -38,5 +40,7 @@ namespace ICSharpCode.SharpDevelop.Dom
/// Either oldPart or newPart may be null when adding/removed a part.
/// </summary>
void Update(IUnresolvedTypeDefinition oldPart, IUnresolvedTypeDefinition newPart);
IFieldModel AddField(Accessibility accessiblity, IType type, string name);
}
}

7
src/Main/Base/Project/Dom/ModelCollectionLinq.cs

@ -30,6 +30,13 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -30,6 +30,13 @@ namespace ICSharpCode.SharpDevelop.Dom
}
#endregion
#region Concat
public static IModelCollection<T> Concat<T>(this IModelCollection<T> input1, IModelCollection<T> input2)
{
return new ImmutableModelCollection<IModelCollection<T>>(new [] { input1, input2 }).SelectMany(c => c);
}
#endregion
#region Where
public static IModelCollection<TSource> Where<TSource>(this IModelCollection<TSource> source, Func<TSource, bool> predicate)
{

2
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -90,7 +90,9 @@ @@ -90,7 +90,9 @@
<Compile Include="Dom\IMemberModel.cs" />
<Compile Include="Dom\IMethodModel.cs" />
<Compile Include="Dom\IModelFactory.cs" />
<Compile Include="Dom\INamespaceModel.cs" />
<Compile Include="Dom\IPropertyModel.cs" />
<Compile Include="Dom\ISymbolModel.cs" />
<Compile Include="Dom\ITypeDefinitionModel.cs" />
<Compile Include="Dom\ITypeDefinitionModelCollection.cs" />
<Compile Include="Dom\IEntityModel.cs" />

13
src/Main/SharpDevelop/Dom/TypeDefinitionModel.cs

@ -46,6 +46,10 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -46,6 +46,10 @@ namespace ICSharpCode.SharpDevelop.Dom
get { return SymbolKind.TypeDefinition; }
}
public TypeKind TypeKind {
get { return parts[0].Kind; }
}
public Accessibility Accessibility {
get {
var td = Resolve();
@ -71,6 +75,10 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -71,6 +75,10 @@ namespace ICSharpCode.SharpDevelop.Dom
get { return fullTypeName.Name; }
}
public string Namespace {
get { return fullTypeName.TopLevelTypeName.Namespace; }
}
#region Resolve
public ITypeDefinition Resolve()
{
@ -307,5 +315,10 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -307,5 +315,10 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
#endregion
public IFieldModel AddField(Accessibility accessiblity, IType type, string name)
{
throw new NotImplementedException();
}
}
}

Loading…
Cancel
Save