29 changed files with 635 additions and 649 deletions
@ -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;
|
} |
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
@ -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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
@ -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; } |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
@ -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));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -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));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
@ -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));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -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; } |
||||||
|
} |
||||||
|
} |
@ -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); }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
@ -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); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
@ -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));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -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"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -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);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -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);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -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; } |
||||||
|
} |
||||||
|
} |
@ -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; } |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue