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