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

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

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

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

@ -1,27 +1,34 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System; using System;
//using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.NRefactory.TypeSystem;
// using ICSharpCode.SharpDevelop.Dom;
//namespace ICSharpCode.PackageManagement.EnvDTE
//{ namespace ICSharpCode.PackageManagement.EnvDTE
// public class CodeAttribute2 : CodeAttribute, global::EnvDTE.CodeAttribute2 {
// { public class CodeAttribute2 : CodeAttribute, global::EnvDTE.CodeAttribute2
// IAttribute attribute; {
// public CodeAttribute2()
// public CodeAttribute2() {
// { }
// }
// public CodeAttribute2(IAttribute attribute)
// public CodeAttribute2(IAttribute attribute) : base(attribute)
// : base(attribute) {
// { }
// this.attribute = attribute;
// } public virtual global::EnvDTE.CodeElements Arguments {
// get {
// public virtual global::EnvDTE.CodeElements Arguments { var list = new CodeElementsList<CodeAttributeArgument>();
// get { return new CodeAttributeArguments(attribute); } 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 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System; using System;
// using ICSharpCode.NRefactory.CSharp.Refactoring;
//namespace ICSharpCode.PackageManagement.EnvDTE using ICSharpCode.NRefactory.Semantics;
//{
// public class CodeAttributeArgument : CodeElement, global::EnvDTE.CodeAttributeArgument namespace ICSharpCode.PackageManagement.EnvDTE
// { {
// string name; public class CodeAttributeArgument : CodeElement, global::EnvDTE.CodeAttributeArgument
// string value; {
// string name;
// public CodeAttributeArgument() string value;
// {
// } public CodeAttributeArgument()
// {
// public CodeAttributeArgument(string name, object value) }
// {
// this.name = name; public CodeAttributeArgument(string name, string value)
// this.value = GetValue(value); {
// } this.name = name;
// this.value = value;
// string GetValue(object value) }
// {
// if (value is string) { public CodeAttributeArgument(string name, ResolveResult value)
// return String.Format("\"{0}\"", value); {
// } this.name = name;
// return value.ToString(); this.value = GetValue(value);
// } }
//
// public override string Name { string GetValue(ResolveResult value)
// get { return name; } {
// } var astBuilder = new TypeSystemAstBuilder();
// var ast = astBuilder.ConvertConstantValue(value);
// public virtual string Value { return ast.ToString();
// get { return value; } }
// }
// } 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 @@
//// 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 @@
//// 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 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System; using System;
//using ICSharpCode.SharpDevelop.Dom; using System.Linq;
// using ICSharpCode.NRefactory.TypeSystem;
//namespace ICSharpCode.PackageManagement.EnvDTE using ICSharpCode.SharpDevelop.Dom;
//{ using ICSharpCode.SharpDevelop.Project;
// public class CodeClass : CodeType, global::EnvDTE.CodeClass
// { namespace ICSharpCode.PackageManagement.EnvDTE
// public CodeClass(IProjectContent projectContent, IClass c) {
// : base(projectContent, c) public class CodeClass : CodeType, global::EnvDTE.CodeClass
// { {
// } public CodeClass(CodeModelContext context, ITypeDefinitionModel typeModel)
// : base(context, typeModel)
// public CodeClass() {
// { }
// }
// public CodeClass()
// public override global::EnvDTE.vsCMElement Kind { {
// get { return global::EnvDTE.vsCMElement.vsCMElementClass; } }
// }
// public override global::EnvDTE.vsCMElement Kind {
// public virtual global::EnvDTE.CodeElements ImplementedInterfaces { get { return global::EnvDTE.vsCMElement.vsCMElementClass; }
// get { return new ImplementedInterfacesOnClass(ProjectContent, Class); } }
// }
// public virtual global::EnvDTE.CodeElements ImplementedInterfaces {
// public virtual global::EnvDTE.CodeVariable AddVariable(string name, object type, object Position = null, global::EnvDTE.vsCMAccess Access = global::EnvDTE.vsCMAccess.vsCMAccessPublic, object Location = null) get {
// { var list = new CodeElementsList<CodeType>();
// var codeGenerator = new ClassCodeGenerator(Class); var td = typeModel.Resolve();
// return codeGenerator.AddPublicVariable(name, (string)type); 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
public class CodeElement : global::EnvDTE.CodeElementBase, global::EnvDTE.CodeElement public class CodeElement : global::EnvDTE.CodeElementBase, global::EnvDTE.CodeElement
{ {
DTE dte; DTE dte;
IEntityModel entityModel; protected readonly CodeModelContext context;
readonly ISymbolModel symbolModel;
public CodeElement() public CodeElement()
{ {
} }
public CodeElement(IEntityModel entityModel) public CodeElement(CodeModelContext context, ISymbolModel symbolModel)
{ {
this.entityModel = entityModel; this.context = context;
this.Language = entityModel.ParentProject.GetCodeModelLanguage(); 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 { public virtual string Name {
get { return entityModel.Name; } get { return symbolModel.Name; }
} }
public virtual string Language { get; protected set; } public virtual string Language { get; protected set; }
@ -40,7 +66,14 @@ namespace ICSharpCode.PackageManagement.EnvDTE
return null; 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 { public virtual global::EnvDTE.DTE DTE {
get { get {

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

@ -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;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.PackageManagement.EnvDTE 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() public CodeElementsList()
{ {
} }
protected virtual void AddCodeElement(CodeElement element) #region EnvDTE.CodeElements implementation
{
elements.Add(element);
}
public int Count { public int Count {
get { return elements.Count; } get { return elements.Count; }
} }
@ -30,22 +28,79 @@ namespace ICSharpCode.PackageManagement.EnvDTE
return elements.GetEnumerator(); return elements.GetEnumerator();
} }
public global::EnvDTE.CodeElement Item(object index) global::EnvDTE.CodeElement global::EnvDTE.CodeElements.Item(object index)
{ {
if (index is int) { 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]; return elements[index - 1];
} }
global::EnvDTE.CodeElement Item(string name) global::EnvDTE.CodeElement GetItem(string name)
{ {
return elements.Single(item => item.Name == 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 @@
// 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 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System; using System;
//using ICSharpCode.SharpDevelop.Dom; using System.Collections.Generic;
// using ICSharpCode.SharpDevelop.Dom;
//namespace ICSharpCode.PackageManagement.EnvDTE
//{ namespace ICSharpCode.PackageManagement.EnvDTE
// public class CodeNamespace : CodeElement, global::EnvDTE.CodeNamespace {
// { public class CodeNamespace : CodeElement, global::EnvDTE.CodeNamespace
// NamespaceName namespaceName; {
// IProjectContent projectContent; readonly INamespaceModel model;
//
// public CodeNamespace(IProjectContent projectContent, string qualifiedName) public CodeNamespace(CodeModelContext context, INamespaceModel model)
// : this(projectContent, new NamespaceName(qualifiedName)) : base(context, model)
// { {
// } this.model = model;
// }
// public CodeNamespace(IProjectContent projectContent, NamespaceName namespaceName)
// { public override global::EnvDTE.vsCMElement Kind {
// this.projectContent = projectContent; get { return global::EnvDTE.vsCMElement.vsCMElementNamespace; }
// this.namespaceName = namespaceName; }
// this.InfoLocation = global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationExternal;
// this.Language = projectContent.GetCodeModelLanguage(); public override global::EnvDTE.vsCMInfoLocation InfoLocation {
// } get { return global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationExternal; }
// }
// public override global::EnvDTE.vsCMElement Kind {
// get { return global::EnvDTE.vsCMElement.vsCMElementNamespace; } public string FullName {
// } get { return model.FullName; }
// }
// internal NamespaceName NamespaceName {
// get { return namespaceName; } public virtual global::EnvDTE.CodeElements Members {
// } get {
// IModelCollection<CodeElement> namespaceMembers = model.ChildNamespaces.Select(ns => new CodeNamespace(context, ns));
// public string FullName { IModelCollection<CodeElement> typeMembers = model.Types.Select(td => CodeType.Create(context, td));
// get { return namespaceName.QualifiedName; } return namespaceMembers.Concat(typeMembers).AsCodeElements();
// } }
// }
// public override string Name { }
// get { return namespaceName.LastPart; } }
// }
//
// public virtual global::EnvDTE.CodeElements Members {
// get { return new CodeElementsInNamespace(projectContent, namespaceName); }
// }
// }
//}

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

@ -1,91 +1,157 @@
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//
//using System; using System;
//using System.Linq; using System.Collections.Generic;
//using ICSharpCode.SharpDevelop.Dom; using System.Linq;
//using ICSharpCode.SharpDevelop.Project; using System.Text;
//
//namespace ICSharpCode.PackageManagement.EnvDTE using ICSharpCode.NRefactory.TypeSystem;
//{ using ICSharpCode.SharpDevelop;
// public class CodeType : CodeElement, global::EnvDTE.CodeType using ICSharpCode.SharpDevelop.Dom;
// { using ICSharpCode.SharpDevelop.Project;
// CodeTypeMembers members;
// namespace ICSharpCode.PackageManagement.EnvDTE
// /// <summary> {
// /// Note that projectContent may be different to the IClass.ProjectContent since the class public class CodeType : CodeElement, global::EnvDTE.CodeType
// /// is retrieved from the namespace contents and could belong to a separate project or {
// /// referenced assembly. protected readonly ITypeDefinitionModel typeModel;
// /// </summary> CodeElementsList<CodeElement> members;
// public CodeType(IProjectContent projectContent, IClass c)
// : base(c) public static CodeType Create(CodeModelContext context, IType type)
// { {
// this.Class = c; var typeDef = type.GetDefinition();
// this.ProjectContent = projectContent; if (typeDef != null) {
// InfoLocation = GetInfoLocation(projectContent, c); var typeModel = typeDef.GetModel();
// } if (typeModel != null)
// return Create(context, typeModel);
// global::EnvDTE.vsCMInfoLocation GetInfoLocation(IProjectContent projectContent, IClass c) }
// { return null;
// if (projectContent.Project == c.ProjectContent.Project) { }
// return global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationProject;
// } public static CodeType Create(CodeModelContext context, ITypeDefinitionModel typeModel)
// return global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationExternal; {
// } switch (typeModel.TypeKind) {
// case TypeKind.Class:
// public CodeType() case TypeKind.Module:
// { goto default;
// } case TypeKind.Interface:
// goto default;
// protected IClass Class { get; private set; } case TypeKind.Struct:
// protected IProjectContent ProjectContent { get; private set; } case TypeKind.Void:
// goto default;
// public virtual global::EnvDTE.vsCMAccess Access { case TypeKind.Delegate:
// get { return GetAccess(); } goto default;
// set { } case TypeKind.Enum:
// } goto default;
// default:
// public virtual string FullName { return new CodeType(context, typeModel);
// get { return Class.FullyQualifiedName; } }
// } }
//
// public virtual global::EnvDTE.CodeElements Members { /// <summary>
// get { /// Note that projectContent may be different to the IClass.ProjectContent since the class
// if (members == null) { /// is retrieved from the namespace contents and could belong to a separate project or
// members = new CodeTypeMembers(ProjectContent, Class); /// referenced assembly.
// } /// </summary>
// return members; public CodeType(CodeModelContext context, ITypeDefinitionModel typeModel)
// } : base(context, typeModel)
// } {
// this.typeModel = typeModel;
// public virtual global::EnvDTE.CodeElements Bases { }
// get { return new CodeTypeBaseTypes(ProjectContent, Class); }
// } public CodeType()
// {
// public virtual global::EnvDTE.CodeElements Attributes { }
// get { return new CodeAttributes(Class); }
// } public virtual global::EnvDTE.vsCMAccess Access {
// get { return typeModel.Accessibility.ToAccess(); }
// public virtual global::EnvDTE.CodeNamespace Namespace { set { typeModel.Accessibility = value.ToAccessibility(); }
// get { return new FileCodeModelCodeNamespace(ProjectContent, Class.Namespace); } }
// }
// public virtual string FullName {
// public virtual global::EnvDTE.ProjectItem ProjectItem { get {
// get { var fullTypeName = typeModel.FullTypeName;
// if (ProjectContent.Project != null) { StringBuilder b = new StringBuilder();
// return new ProjectItem(ProjectContent, Class); if (!string.IsNullOrEmpty(fullTypeName.TopLevelTypeName.Namespace)) {
// } b.Append(fullTypeName.TopLevelTypeName.Namespace);
// return null; b.Append('.');
// } }
// } b.Append(fullTypeName.TopLevelTypeName.Name);
// for (int i = 0; i < fullTypeName.NestingLevel; i++) {
// /// <summary> b.Append('.');
// /// Returns true if the current type matches the fully qualified name or any of its b.Append(fullTypeName.GetNestedTypeName(i));
// /// base types are a match. }
// /// </summary> return b.ToString();
// protected override bool GetIsDerivedFrom(string fullName) }
// { }
// return Class.IsDerivedFrom(fullName);
// } 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 @@
//// 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 @@
// 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
public class CodeVariable : CodeElement, global::EnvDTE.CodeVariable public class CodeVariable : CodeElement, global::EnvDTE.CodeVariable
{ {
readonly IFieldModel field; readonly IFieldModel field;
readonly IDocumentLoader documentLoader;
public CodeVariable() public CodeVariable()
{ {
} }
public CodeVariable(IFieldModel field, IDocumentLoader documentLoader) public CodeVariable(CodeModelContext context, IFieldModel field)
: base(context, field)
{ {
this.field = field; this.field = field;
this.documentLoader = documentLoader;
} }
public override global::EnvDTE.vsCMElement Kind { public override global::EnvDTE.vsCMElement Kind {
@ -32,12 +31,12 @@ namespace ICSharpCode.PackageManagement.EnvDTE
public override global::EnvDTE.TextPoint GetStartPoint() public override global::EnvDTE.TextPoint GetStartPoint()
{ {
return TextPoint.CreateStartPoint(field.Region, documentLoader); return TextPoint.CreateStartPoint(context, field.Region);
} }
public override global::EnvDTE.TextPoint GetEndPoint() 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 @@
// /// </summary> // /// </summary>
// public class FileCodeModelCodeNamespace : CodeNamespace // public class FileCodeModelCodeNamespace : CodeNamespace
// { // {
// FileCodeModelCodeNamespaceMembers members = new FileCodeModelCodeNamespaceMembers();
//
// public FileCodeModelCodeNamespace(IProjectContent projectContent, string namespaceName) // public FileCodeModelCodeNamespace(IProjectContent projectContent, string namespaceName)
// : base(projectContent, namespaceName) // : base(projectContent, namespaceName)
// { // {

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

@ -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 @@
//// 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
return new FileProjectItems(this); return new FileProjectItems(this);
} }
internal static ProjectItem FindByEntity(IProject project, IEntityModel entity)
{
throw new NotImplementedException();
}
// internal ProjectItem(MSBuildBasedProject project, IClass c) // internal ProjectItem(MSBuildBasedProject project, IClass c)
// : this(new Project(project), project.FindFile(c.CompilationUnit.FileName)) // : 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
return new EditPoint(fileName, location, documentLoader); 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
throw new Exception("Invalid value for vsCMAccess"); 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
/// <summary> /// <summary>
/// An NRefactory entity as a model. /// An NRefactory entity as a model.
/// </summary> /// </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> /// <summary>
/// Gets/sets the accessibility of the entity. /// Gets/sets the accessibility of the entity.
/// </summary> /// </summary>
Accessibility Accessibility { get; set; } 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> /// <summary>
/// Resolves the entity in the current solution snapshot. /// Resolves the entity in the current solution snapshot.
/// Returns null if the entity could not be resolved. /// Returns null if the entity could not be resolved.

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

@ -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 @@
// 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
public interface ITypeDefinitionModel : IEntityModel public interface ITypeDefinitionModel : IEntityModel
{ {
FullTypeName FullTypeName { get; } FullTypeName FullTypeName { get; }
string Namespace { get; }
TypeKind TypeKind { get; }
IModelCollection<ITypeDefinitionModel> NestedTypes { get; } IModelCollection<ITypeDefinitionModel> NestedTypes { get; }
IModelCollection<IMemberModel> Members { get; } IModelCollection<IMemberModel> Members { get; }
@ -38,5 +40,7 @@ namespace ICSharpCode.SharpDevelop.Dom
/// Either oldPart or newPart may be null when adding/removed a part. /// Either oldPart or newPart may be null when adding/removed a part.
/// </summary> /// </summary>
void Update(IUnresolvedTypeDefinition oldPart, IUnresolvedTypeDefinition newPart); 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
} }
#endregion #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 #region Where
public static IModelCollection<TSource> Where<TSource>(this IModelCollection<TSource> source, Func<TSource, bool> predicate) 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 @@
<Compile Include="Dom\IMemberModel.cs" /> <Compile Include="Dom\IMemberModel.cs" />
<Compile Include="Dom\IMethodModel.cs" /> <Compile Include="Dom\IMethodModel.cs" />
<Compile Include="Dom\IModelFactory.cs" /> <Compile Include="Dom\IModelFactory.cs" />
<Compile Include="Dom\INamespaceModel.cs" />
<Compile Include="Dom\IPropertyModel.cs" /> <Compile Include="Dom\IPropertyModel.cs" />
<Compile Include="Dom\ISymbolModel.cs" />
<Compile Include="Dom\ITypeDefinitionModel.cs" /> <Compile Include="Dom\ITypeDefinitionModel.cs" />
<Compile Include="Dom\ITypeDefinitionModelCollection.cs" /> <Compile Include="Dom\ITypeDefinitionModelCollection.cs" />
<Compile Include="Dom\IEntityModel.cs" /> <Compile Include="Dom\IEntityModel.cs" />

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

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

Loading…
Cancel
Save