27 changed files with 403 additions and 495 deletions
@ -1,27 +0,0 @@
@@ -1,27 +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;
|
||||
//using ICSharpCode.SharpDevelop.Dom;
|
||||
//using ICSharpCode.SharpDevelop.Editor;
|
||||
//using ICSharpCode.SharpDevelop.Gui;
|
||||
//using ICSharpCode.SharpDevelop.Refactoring;
|
||||
//
|
||||
//namespace ICSharpCode.PackageManagement
|
||||
//{
|
||||
// public class DocumentNamespaceCreator : IDocumentNamespaceCreator
|
||||
// {
|
||||
// public void AddNamespace(ICompilationUnit compilationUnit, string newNamespace)
|
||||
// {
|
||||
// if (WorkbenchSingleton.InvokeRequired) {
|
||||
// WorkbenchSingleton.SafeThreadCall(() => AddNamespace(compilationUnit, newNamespace));
|
||||
// } else {
|
||||
// IViewContent view = FileService.OpenFile(compilationUnit.FileName);
|
||||
// var textEditor = view as ITextEditorProvider;
|
||||
// IDocument document = textEditor.TextEditor.Document;
|
||||
// NamespaceRefactoringService.AddUsingDeclaration(compilationUnit, document, newNamespace, false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,98 +1,100 @@
@@ -1,98 +1,100 @@
|
||||
//// 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 CodeFunction : CodeElement, global::EnvDTE.CodeFunction
|
||||
// {
|
||||
// IDocumentLoader documentLoader;
|
||||
// IVirtualMethodUpdater methodUpdater;
|
||||
//
|
||||
// public CodeFunction(IMethod method)
|
||||
// : this(method, new DocumentLoader(), new VirtualMethodUpdater(method))
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public CodeFunction(IMethod method, IDocumentLoader documentLoader, IVirtualMethodUpdater methodUpdater)
|
||||
// : base(method)
|
||||
// {
|
||||
// this.Method = method;
|
||||
// this.documentLoader = documentLoader;
|
||||
// this.methodUpdater = methodUpdater;
|
||||
// }
|
||||
//
|
||||
// public CodeFunction()
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public CodeFunction(IProperty property)
|
||||
// : base(property)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// protected IMethodOrProperty Method { get; private set; }
|
||||
//
|
||||
// public override global::EnvDTE.vsCMElement Kind {
|
||||
// get { return global::EnvDTE.vsCMElement.vsCMElementFunction; }
|
||||
// }
|
||||
//
|
||||
// public virtual global::EnvDTE.vsCMAccess Access {
|
||||
// get { return GetAccess(); }
|
||||
// set { }
|
||||
// }
|
||||
//
|
||||
// public override global::EnvDTE.TextPoint GetStartPoint()
|
||||
// {
|
||||
// return new TextPoint(Method.GetStartPosition(), documentLoader);
|
||||
// }
|
||||
//
|
||||
// public override global::EnvDTE.TextPoint GetEndPoint()
|
||||
// {
|
||||
// return new TextPoint(Method.GetEndPosition(), documentLoader);
|
||||
// }
|
||||
//
|
||||
// public virtual global::EnvDTE.CodeElements Parameters {
|
||||
// get { return new CodeParameters(Method.ProjectContent, Method.Parameters); }
|
||||
// }
|
||||
//
|
||||
// public virtual global::EnvDTE.CodeTypeRef2 Type {
|
||||
// get { return new CodeTypeRef2(Method.ProjectContent, this, Method.ReturnType); }
|
||||
// }
|
||||
//
|
||||
// public virtual global::EnvDTE.CodeElements Attributes {
|
||||
// get { return new CodeAttributes(Method); }
|
||||
// }
|
||||
//
|
||||
// public virtual bool CanOverride {
|
||||
// get { return Method.IsOverridable; }
|
||||
// set {
|
||||
// if (value) {
|
||||
// methodUpdater.MakeMethodVirtual();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public virtual global::EnvDTE.vsCMFunction FunctionKind {
|
||||
// get { return GetFunctionKind(); }
|
||||
// }
|
||||
//
|
||||
// global::EnvDTE.vsCMFunction GetFunctionKind()
|
||||
// {
|
||||
// if (Method.IsConstructor()) {
|
||||
// return global::EnvDTE.vsCMFunction.vsCMFunctionConstructor;
|
||||
// }
|
||||
// return global::EnvDTE.vsCMFunction.vsCMFunctionFunction;
|
||||
// }
|
||||
//
|
||||
// public virtual bool IsShared {
|
||||
// get { return Method.IsStatic; }
|
||||
// }
|
||||
//
|
||||
// public virtual bool MustImplement {
|
||||
// get { return Method.IsAbstract; }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// 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 CodeFunction : CodeElement, global::EnvDTE.CodeFunction |
||||
{ |
||||
protected readonly IMethodModel methodModel; |
||||
|
||||
public CodeFunction(CodeModelContext context, IMethodModel methodModel) |
||||
: base(context, methodModel) |
||||
{ |
||||
} |
||||
|
||||
public CodeFunction() |
||||
{ |
||||
} |
||||
|
||||
public override global::EnvDTE.vsCMElement Kind { |
||||
get { return global::EnvDTE.vsCMElement.vsCMElementFunction; } |
||||
} |
||||
|
||||
public virtual global::EnvDTE.vsCMAccess Access { |
||||
get { return methodModel.Accessibility.ToAccess(); } |
||||
set { |
||||
var method = methodModel.Resolve(); |
||||
if (method == null) |
||||
throw new NotSupportedException(); |
||||
context.CodeGenerator.ChangeAccessibility(method, value.ToAccessibility()); |
||||
} |
||||
} |
||||
|
||||
public virtual global::EnvDTE.CodeElements Parameters { |
||||
get { |
||||
var list = new CodeElementsList<CodeParameter2>(); |
||||
var method = (IParameterizedMember)methodModel.Resolve(); |
||||
if (method != null) { |
||||
foreach (var p in method.Parameters) { |
||||
list.Add(new CodeParameter2(context, p)); |
||||
} |
||||
} |
||||
return list; |
||||
} |
||||
} |
||||
|
||||
public virtual global::EnvDTE.CodeTypeRef2 Type { |
||||
get { |
||||
var method = methodModel.Resolve(); |
||||
if (method == null) |
||||
return null; |
||||
return new CodeTypeRef2(context, this, method.ReturnType); |
||||
} |
||||
} |
||||
|
||||
public virtual global::EnvDTE.CodeElements Attributes { |
||||
get { return GetAttributes(methodModel); } |
||||
} |
||||
|
||||
public virtual bool CanOverride { |
||||
get { return methodModel.IsOverridable; } |
||||
set { |
||||
if (value && !methodModel.IsOverridable) { |
||||
var method = methodModel.Resolve(); |
||||
if (method != null) { |
||||
context.CodeGenerator.MakeVirtual(method); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public virtual global::EnvDTE.vsCMFunction FunctionKind { |
||||
get { return GetFunctionKind(); } |
||||
} |
||||
|
||||
global::EnvDTE.vsCMFunction GetFunctionKind() |
||||
{ |
||||
switch (methodModel.SymbolKind) { |
||||
case SymbolKind.Constructor: |
||||
return global::EnvDTE.vsCMFunction.vsCMFunctionConstructor; |
||||
//case SymbolKind.Destructor:
|
||||
//case SymbolKind.Accessor:
|
||||
//case SymbolKind.Operator:
|
||||
default: |
||||
return global::EnvDTE.vsCMFunction.vsCMFunctionFunction; |
||||
} |
||||
} |
||||
|
||||
public virtual bool IsShared { |
||||
get { return methodModel.IsStatic; } |
||||
} |
||||
|
||||
public virtual bool MustImplement { |
||||
get { return methodModel.IsAbstract; } |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,40 +1,40 @@
@@ -1,40 +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 CodeFunction2 : CodeFunction, global::EnvDTE.CodeFunction2
|
||||
// {
|
||||
// public CodeFunction2(IMethod method)
|
||||
// : base(method)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public virtual bool IsGeneric {
|
||||
// get { return Method.HasTypeParameters(); }
|
||||
// }
|
||||
//
|
||||
// public virtual global::EnvDTE.vsCMOverrideKind OverrideKind {
|
||||
// get { return GetOverrideKind(); }
|
||||
// }
|
||||
//
|
||||
// global::EnvDTE.vsCMOverrideKind GetOverrideKind()
|
||||
// {
|
||||
// if (Method.IsAbstract) {
|
||||
// return global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindAbstract;
|
||||
// } else if (Method.IsVirtual) {
|
||||
// return global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindVirtual;
|
||||
// } else if (Method.IsOverride) {
|
||||
// return global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindOverride;
|
||||
// } else if (Method.IsSealed) {
|
||||
// return global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindSealed;
|
||||
// } else if (Method.IsNew) {
|
||||
// return global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindNew;
|
||||
// }
|
||||
// return global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindNone;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// 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 CodeFunction2 : CodeFunction, global::EnvDTE.CodeFunction2 |
||||
{ |
||||
public CodeFunction2(CodeModelContext context, IMethodModel methodModel) |
||||
: base(context, methodModel) |
||||
{ |
||||
} |
||||
|
||||
public virtual bool IsGeneric { |
||||
get { return methodModel.TypeParameterCount > 0; } |
||||
} |
||||
|
||||
public virtual global::EnvDTE.vsCMOverrideKind OverrideKind { |
||||
get { return GetOverrideKind(); } |
||||
} |
||||
|
||||
global::EnvDTE.vsCMOverrideKind GetOverrideKind() |
||||
{ |
||||
global::EnvDTE.vsCMOverrideKind kind = 0; |
||||
if (methodModel.IsAbstract) |
||||
kind |= global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindAbstract; |
||||
if (methodModel.IsOverride) |
||||
kind |= global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindOverride; |
||||
if (methodModel.IsVirtual && !methodModel.IsAbstract && !methodModel.IsOverride) |
||||
kind |= global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindVirtual; |
||||
if (methodModel.IsSealed) |
||||
kind |= global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindSealed; |
||||
if (methodModel.IsShadowing) |
||||
kind |= global::EnvDTE.vsCMOverrideKind.vsCMOverrideKindNew; |
||||
return kind; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,16 +0,0 @@
@@ -1,16 +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 CodeGetterFunction : CodeGetterOrSetterFunction
|
||||
// {
|
||||
// public CodeGetterFunction(IProperty property)
|
||||
// : base(property, property.GetterModifiers)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,29 +0,0 @@
@@ -1,29 +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 CodeGetterOrSetterFunction : CodeFunction
|
||||
// {
|
||||
// ModifierEnum modifier;
|
||||
//
|
||||
// public CodeGetterOrSetterFunction(IProperty property, ModifierEnum modifier)
|
||||
// : base(property)
|
||||
// {
|
||||
// this.modifier = modifier;
|
||||
// }
|
||||
//
|
||||
// public override global::EnvDTE.vsCMAccess Access {
|
||||
// get {
|
||||
// if (modifier == ModifierEnum.None) {
|
||||
// return base.Access;
|
||||
// }
|
||||
// return global::EnvDTE.vsCMAccess.vsCMAccessPrivate;
|
||||
// }
|
||||
// set { }
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,40 +1,33 @@
@@ -1,40 +1,33 @@
|
||||
//// 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 CodeImport : CodeElement, global::EnvDTE.CodeImport
|
||||
// {
|
||||
// IUsing import;
|
||||
//
|
||||
// public CodeImport()
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public CodeImport(IUsing import)
|
||||
// {
|
||||
// this.import = import;
|
||||
// this.Namespace = GetNamespace();
|
||||
// }
|
||||
//
|
||||
// string GetNamespace()
|
||||
// {
|
||||
// if (import.Usings.Any()) {
|
||||
// return import.Usings.First();
|
||||
// } else if (import.HasAliases) {
|
||||
// return import.Aliases.Values.First().FullyQualifiedName;
|
||||
// }
|
||||
// return String.Empty;
|
||||
// }
|
||||
//
|
||||
// public string Namespace { get; private set; }
|
||||
//
|
||||
// public override global::EnvDTE.vsCMElement Kind {
|
||||
// get { return global::EnvDTE.vsCMElement.vsCMElementImportStmt; }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// 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 CodeImport : CodeElement, global::EnvDTE.CodeImport |
||||
{ |
||||
string namespaceName; |
||||
|
||||
public CodeImport() |
||||
{ |
||||
} |
||||
|
||||
public CodeImport(string namespaceName) |
||||
{ |
||||
this.namespaceName = namespaceName; |
||||
} |
||||
|
||||
public string Namespace { |
||||
get { |
||||
return namespaceName; |
||||
} |
||||
} |
||||
|
||||
public override global::EnvDTE.vsCMElement Kind { |
||||
get { return global::EnvDTE.vsCMElement.vsCMElementImportStmt; } |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,16 +0,0 @@
@@ -1,16 +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 CodeSetterFunction : CodeGetterOrSetterFunction
|
||||
// {
|
||||
// public CodeSetterFunction(IProperty property)
|
||||
// : base(property, property.SetterModifiers)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,45 +1,89 @@
@@ -1,45 +1,89 @@
|
||||
//// 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;
|
||||
//using ICSharpCode.SharpDevelop.Project;
|
||||
//
|
||||
//namespace ICSharpCode.PackageManagement.EnvDTE
|
||||
//{
|
||||
// public class FileCodeModel2 : MarshalByRefObject, global::EnvDTE.FileCodeModel2
|
||||
// {
|
||||
// Project project;
|
||||
// FileProjectItem projectItem;
|
||||
// IDocumentNamespaceCreator namespaceCreator;
|
||||
//
|
||||
// public FileCodeModel2(Project project, FileProjectItem projectItem)
|
||||
// : this(project, projectItem, new DocumentNamespaceCreator())
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public FileCodeModel2(
|
||||
// Project project,
|
||||
// FileProjectItem projectItem,
|
||||
// IDocumentNamespaceCreator namespaceCreator)
|
||||
// {
|
||||
// this.project = project;
|
||||
// this.projectItem = projectItem;
|
||||
// this.namespaceCreator = namespaceCreator;
|
||||
// }
|
||||
//
|
||||
// public global::EnvDTE.CodeElements CodeElements {
|
||||
// get { return new FileCodeModelCodeElements(GetCompilationUnit()); }
|
||||
// }
|
||||
//
|
||||
// public void AddImport(string name, object position = null, string alias = null)
|
||||
// {
|
||||
// namespaceCreator.AddNamespace(GetCompilationUnit(), name);
|
||||
// }
|
||||
//
|
||||
// ICompilationUnit GetCompilationUnit()
|
||||
// {
|
||||
// return project.GetCompilationUnit(projectItem.FileName);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// 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 ICSharpCode.Core; |
||||
using ICSharpCode.NRefactory.CSharp; |
||||
using ICSharpCode.NRefactory.CSharp.TypeSystem; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.PackageManagement.EnvDTE |
||||
{ |
||||
public class FileCodeModel2 : MarshalByRefObject, global::EnvDTE.FileCodeModel2 |
||||
{ |
||||
readonly CodeModelContext context; |
||||
CodeElementsList<CodeElement> codeElements = new CodeElementsList<CodeElement>(); |
||||
Dictionary<string, FileCodeModelCodeNamespace> namespaces = new Dictionary<string, FileCodeModelCodeNamespace>(); |
||||
|
||||
public FileCodeModel2(CodeModelContext context) |
||||
{ |
||||
if (context == null || context.FilteredFileName == null) |
||||
throw new ArgumentException("context must be restricted to a file"); |
||||
this.context = context; |
||||
var compilation = SD.ParserService.GetCompilation(context.CurrentProject); |
||||
|
||||
var projectContent = compilation.MainAssembly.UnresolvedAssembly as IProjectContent; |
||||
if (projectContent != null) { |
||||
IUnresolvedFile file = projectContent.GetFile(context.FilteredFileName); |
||||
if (file != null) { |
||||
var csharpFile = file as CSharpUnresolvedFile; |
||||
if (csharpFile != null) |
||||
AddUsings(codeElements, csharpFile.RootUsingScope, compilation); |
||||
|
||||
var resolveContext = new SimpleTypeResolveContext(compilation.MainAssembly); |
||||
AddTypes(file.TopLevelTypeDefinitions |
||||
.Select(td => td.Resolve(resolveContext) as ITypeDefinition) |
||||
.Where(td => td != null).Distinct()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public global::EnvDTE.CodeElements CodeElements { |
||||
get { return codeElements; } |
||||
} |
||||
|
||||
void AddTypes(IEnumerable<ITypeDefinition> types) |
||||
{ |
||||
foreach (var td in types) { |
||||
var model = td.GetModel(); |
||||
if (model == null) |
||||
continue; |
||||
var codeType = CodeType.Create(context, td); |
||||
if (string.IsNullOrEmpty(td.Namespace)) |
||||
codeElements.Add(codeType); |
||||
else |
||||
GetNamespace(td.Namespace).AddMember(codeType); |
||||
} |
||||
codeElements.AddRange(types.Select(td => CodeType.Create(context, td))); |
||||
} |
||||
|
||||
public static void AddUsings(CodeElementsList<CodeElement> codeElements, UsingScope usingScope, ICompilation compilation) |
||||
{ |
||||
var resolvedUsingScope = usingScope.Resolve(compilation); |
||||
foreach (var ns in resolvedUsingScope.Usings) { |
||||
codeElements.Add(new CodeImport(ns.FullName)); |
||||
} |
||||
} |
||||
|
||||
public void AddImport(string name, object position = null, string alias = null) |
||||
{ |
||||
context.CodeGenerator.AddImport(FileName.Create(context.FilteredFileName), name); |
||||
} |
||||
|
||||
internal FileCodeModelCodeNamespace GetNamespace(string namespaceName) |
||||
{ |
||||
FileCodeModelCodeNamespace ns; |
||||
if (!namespaces.TryGetValue(namespaceName, out ns)) { |
||||
ns = new FileCodeModelCodeNamespace(context, namespaceName); |
||||
namespaces.Add(namespaceName, ns); |
||||
codeElements.Add(ns); |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,36 +1,42 @@
@@ -1,36 +1,42 @@
|
||||
//// 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
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// File code model namespaces take the full name of the namespace that a class
|
||||
// /// is inside. So for the FileCodeModelNamespace class the CodeNamespace.Name
|
||||
// /// would be ICSharpCode.PackageManagement.EnvDTE.
|
||||
// /// This differs from the CodeModel CodeNamespace which breaks up the namespaces into
|
||||
// /// parts.
|
||||
// /// </summary>
|
||||
// public class FileCodeModelCodeNamespace : CodeNamespace
|
||||
// {
|
||||
// public FileCodeModelCodeNamespace(IProjectContent projectContent, string namespaceName)
|
||||
// : base(projectContent, namespaceName)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public override string Name {
|
||||
// get { return base.FullName; }
|
||||
// }
|
||||
//
|
||||
// public override global::EnvDTE.CodeElements Members {
|
||||
// get { return members; }
|
||||
// }
|
||||
//
|
||||
// public void AddClass(IProjectContent projectContent, IClass c)
|
||||
// {
|
||||
// members.AddClass(projectContent, c);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// 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 |
||||
{ |
||||
/// <summary>
|
||||
/// File code model namespaces take the full name of the namespace that a class
|
||||
/// is inside. So for the FileCodeModelNamespace class the CodeNamespace.Name
|
||||
/// would be ICSharpCode.PackageManagement.EnvDTE.
|
||||
/// This differs from the CodeModel CodeNamespace which breaks up the namespaces into
|
||||
/// parts.
|
||||
/// </summary>
|
||||
public class FileCodeModelCodeNamespace : CodeNamespace |
||||
{ |
||||
public FileCodeModelCodeNamespace(CodeModelContext context, string namespaceName) |
||||
: base(context, namespaceName) |
||||
{ |
||||
} |
||||
|
||||
public override string Name { |
||||
get { return base.FullName; } |
||||
} |
||||
|
||||
public override global::EnvDTE.vsCMInfoLocation InfoLocation { |
||||
get { return global::EnvDTE.vsCMInfoLocation.vsCMInfoLocationProject; } |
||||
} |
||||
|
||||
CodeElementsList<CodeElement> members = new CodeElementsList<CodeElement>(); |
||||
|
||||
public override global::EnvDTE.CodeElements Members { |
||||
get { return members; } |
||||
} |
||||
|
||||
internal void AddMember(CodeElement member) |
||||
{ |
||||
members.Add(member); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,13 +0,0 @@
@@ -1,13 +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
|
||||
//{
|
||||
// public interface IDocumentNamespaceCreator
|
||||
// {
|
||||
// void AddNamespace(ICompilationUnit compilationUnit, string newNamespace);
|
||||
// }
|
||||
//}
|
@ -1,67 +0,0 @@
@@ -1,67 +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;
|
||||
//using ICSharpCode.SharpDevelop.Dom.Refactoring;
|
||||
//
|
||||
//namespace ICSharpCode.PackageManagement
|
||||
//{
|
||||
// public class VirtualMethodUpdater : IVirtualMethodUpdater
|
||||
// {
|
||||
// public VirtualMethodUpdater(IMethod method)
|
||||
// : this(method, new DocumentLoader())
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public VirtualMethodUpdater(IMethod method, IDocumentLoader documentLoader)
|
||||
// {
|
||||
// this.Method = method;
|
||||
// this.DocumentLoader = documentLoader;
|
||||
// }
|
||||
//
|
||||
// IMethod Method { get; set; }
|
||||
// IDocumentLoader DocumentLoader { get; set; }
|
||||
// IRefactoringDocument Document { get; set; }
|
||||
//
|
||||
// public void MakeMethodVirtual()
|
||||
// {
|
||||
// if (Method.IsVirtual)
|
||||
// return;
|
||||
//
|
||||
// OpenFileContainingMethod();
|
||||
// int offset = GetVirtualKeywordInsertOffset();
|
||||
// InsertVirtualKeyword(offset);
|
||||
// }
|
||||
//
|
||||
// void OpenFileContainingMethod()
|
||||
// {
|
||||
// Document = DocumentLoader.LoadRefactoringDocument(Method.CompilationUnit.FileName);
|
||||
// }
|
||||
//
|
||||
// int GetVirtualKeywordInsertOffset()
|
||||
// {
|
||||
// IRefactoringDocumentLine line = Document.GetLine(Method.Region.BeginLine);
|
||||
// int offset = line.Text.IndexOf("public ", StringComparison.OrdinalIgnoreCase);
|
||||
// if (offset >= 0) {
|
||||
// int publicKeywordLength = 6;
|
||||
// return offset + line.Offset + publicKeywordLength + 1;
|
||||
// }
|
||||
// throw new ApplicationException("Unable to find 'method' declaration.");
|
||||
// }
|
||||
//
|
||||
// void InsertVirtualKeyword(int offset)
|
||||
// {
|
||||
// string virtualKeyword = GetLanguageSpecificVirtualKeyword();
|
||||
// Document.Insert(offset, virtualKeyword + " ");
|
||||
// }
|
||||
//
|
||||
// string GetLanguageSpecificVirtualKeyword()
|
||||
// {
|
||||
// if (Method.ProjectContent.Language == LanguageProperties.VBNet) {
|
||||
// return "Overridable";
|
||||
// }
|
||||
// return "virtual";
|
||||
// }
|
||||
// }
|
||||
//}
|
Loading…
Reference in new issue