Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 11 files changed
  • 0 commit comments
  • 1 contributor
View
192 ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs
@@ -35,6 +35,7 @@
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem;
+using ICSharpCode.NRefactory.CSharp.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp.Completion
{
@@ -358,14 +359,14 @@ IEnumerable<ICompletionData> MagicKeyCompletion (char completionChar, bool contr
var evt = mrr.Member as IEvent;
if (evt == null)
return null;
- var delegateType = evt.ReturnType.Resolve (ctx);
- if (!delegateType.IsDelegate ())
+ var delegateType = evt.ReturnType;
+ if (delegateType.Kind != TypeKind.Delegate)
return null;
var wrapper = new CompletionDataWrapper (this);
if (currentType != null) {
// bool includeProtected = DomType.IncludeProtected (dom, typeFromDatabase, resolver.CallingType);
- foreach (var method in currentType.GetMethods (ctx)) {
+ foreach (var method in currentType.Methods) {
if (MatchDelegate (delegateType, method) /*&& method.IsAccessibleFrom (dom, resolver.CallingType, resolver.CallingMember, includeProtected) &&*/) {
wrapper.AddMember (method);
// data.SetText (data.CompletionText + ";");
@@ -455,12 +456,12 @@ IEnumerable<ICompletionData> MagicKeyCompletion (char completionChar, bool contr
if (initalizerResult != null) {
- foreach (var property in initalizerResult.Item1.Type.GetProperties (ctx)) {
+ foreach (var property in initalizerResult.Item1.Type.GetProperties ()) {
if (!property.IsPublic)
continue;
contextList.AddMember (property);
}
- foreach (var field in initalizerResult.Item1.Type.GetFields (ctx)) {
+ foreach (var field in initalizerResult.Item1.Type.GetFields ()) {
if (!field.IsPublic)
continue;
contextList.AddMember (field);
@@ -470,7 +471,7 @@ IEnumerable<ICompletionData> MagicKeyCompletion (char completionChar, bool contr
return null;
}
if (n != null/* && !(identifierStart.Item2 is TypeDeclaration)*/) {
- csResolver = new CSharpResolver (ctx, System.Threading.CancellationToken.None);
+ csResolver = new CSharpResolver (ctx);
var nodes = new List<AstNode> ();
nodes.Add (n);
if (n.Parent is ICSharpCode.NRefactory.CSharp.Attribute)
@@ -487,10 +488,10 @@ IEnumerable<ICompletionData> MagicKeyCompletion (char completionChar, bool contr
if (n.Parent is ICSharpCode.NRefactory.CSharp.Attribute) {
var resolved = visitor.GetResolveResult (n.Parent);
if (resolved != null && resolved.Type != null) {
- foreach (var property in resolved.Type.GetProperties (ctx).Where (p => p.Accessibility == Accessibility.Public)) {
+ foreach (var property in resolved.Type.GetProperties (p => p.Accessibility == Accessibility.Public)) {
contextList.AddMember (property);
}
- foreach (var field in resolved.Type.GetFields (ctx).Where (p => p.Accessibility == Accessibility.Public)) {
+ foreach (var field in resolved.Type.GetFields (p => p.Accessibility == Accessibility.Public)) {
contextList.AddMember (field);
}
}
@@ -658,17 +659,17 @@ void AddContextCompletion (CompletionDataWrapper wrapper, CSharpResolver state,
}
}
- if (currentMember is IMethod) {
- var method = (IMethod)currentMember;
+ if (currentMember is IUnresolvedMethod) {
+ var method = (IUnresolvedMethod)currentMember;
foreach (var p in method.TypeParameters) {
wrapper.AddTypeParameter (p);
}
}
- Predicate<ITypeDefinition> typePred = null;
+ Predicate<IType> typePred = null;
if (node is Attribute) {
- var attribute = ctx.GetTypeDefinition ("System", "Attribute", 0, StringComparer.Ordinal);
- typePred = t => t.GetAllBaseTypeDefinitions (ctx).Any (bt => bt.Equals (attribute));
+ var attribute = ProjectContent.CreateCompilation ().MainAssembly.GetTypeDefinition ("System", "Attribute", 0);
+ typePred = t => t.GetAllBaseTypeDefinitions ().Any (bt => bt.Equals (attribute));
}
AddTypesAndNamespaces (wrapper, state, node, typePred);
@@ -704,13 +705,13 @@ static bool IsInSwitchContext (AstNode node)
return false;
}
- void AddTypesAndNamespaces (CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Predicate<ITypeDefinition> typePred = null, Predicate<IMember> memberPred = null)
+ void AddTypesAndNamespaces (CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Predicate<IType> typePred = null, Predicate<IMember> memberPred = null)
{
- var currentMember = state.CurrentMember ?? this.currentMember;
+ var currentMember = this.currentMember;
if (currentType != null) {
for (var ct = currentType; ct != null; ct = ct.DeclaringTypeDefinition) {
foreach (var nestedType in ct.NestedTypes) {
- if (typePred == null || typePred (nestedType)) {
+ if (typePred == null || typePred (nestedType.Resolve (ctx))) {
string name = nestedType.Name;
if (node is Attribute && name.EndsWith ("Attribute") && name.Length > "Attribute".Length)
name = name.Substring (0, name.Length - "Attribute".Length);
@@ -719,7 +720,7 @@ void AddTypesAndNamespaces (CompletionDataWrapper wrapper, CSharpResolver state,
}
}
if (currentMember != null) {
- foreach (var member in currentType.Resolve (ctx).GetMembers (ctx)) {
+ foreach (var member in currentType.Resolve (ctx).GetMembers ()) {
if (memberPred == null || memberPred (member))
wrapper.AddMember (member);
}
@@ -729,16 +730,14 @@ void AddTypesAndNamespaces (CompletionDataWrapper wrapper, CSharpResolver state,
}
}
+ /* TODO !!!!!!!!!
+
for (var n = state.CurrentUsingScope; n != null; n = n.Parent) {
foreach (var pair in n.UsingAliases) {
wrapper.AddNamespace ("", pair.Key);
}
-
foreach (var u in n.Usings) {
- var ns = u.ResolveNamespace (ctx);
- if (ns == null)
- continue;
- foreach (var type in ctx.GetTypes (ns.NamespaceName, StringComparer.Ordinal)) {
+ foreach (var type in ctx.GetTypes (u.FullName, StringComparer.Ordinal)) {
if (typePred == null || typePred (type)) {
string name = type.Name;
if (node is Attribute && name.EndsWith ("Attribute") && name.Length > "Attribute".Length)
@@ -757,7 +756,7 @@ void AddTypesAndNamespaces (CompletionDataWrapper wrapper, CSharpResolver state,
foreach (var curNs in ctx.GetNamespaces ().Where (sn => sn.StartsWith (n.NamespaceName) && sn != n.NamespaceName)) {
wrapper.AddNamespace (n.NamespaceName, curNs);
}
- }
+ }*/
}
IEnumerable<ICompletionData> HandleKeywordCompletion (int wordStart, string word)
@@ -851,7 +850,7 @@ IEnumerable<ICompletionData> HandleKeywordCompletion (int wordStart, string word
}
var isAsWrapper = new CompletionDataWrapper (this);
- AddTypesAndNamespaces (isAsWrapper, GetState (), null, t => isAsType == null || t.IsDerivedFrom (isAsType.GetDefinition (), ctx));
+ AddTypesAndNamespaces (isAsWrapper, GetState (), null, t => isAsType == null || t.GetDefinition ().IsDerivedFrom (isAsType.GetDefinition ()));
return isAsWrapper.Result;
// {
// CompletionDataList completionList = new ProjectDomCompletionDataList ();
@@ -1091,19 +1090,19 @@ IEnumerable<ICompletionData> CreateTypeCompletionData (IType hintType, AstType h
{
var wrapper = new CompletionDataWrapper (this);
var state = GetState ();
- Predicate<ITypeDefinition> pred = null;
+ Predicate<IType> pred = null;
if (hintType != null) {
- if (!hintType.Equals (SharedTypes.UnknownType)) {
- var lookup = new MemberLookup (ctx, currentType, ProjectContent);
+ if (hintType.Kind != TypeKind.Unknown) {
+ var lookup = new MemberLookup (currentType.Resolve (ctx).GetDefinition (), ProjectContent.CreateCompilation ().MainAssembly);
pred = t => {
// check if type is in inheritance tree.
- if (hintType.GetDefinition () != null && !t.IsDerivedFrom (hintType.GetDefinition (), ctx))
+ if (hintType.GetDefinition () != null && !t.GetDefinition ().IsDerivedFrom (hintType.GetDefinition ()))
return false;
// check for valid constructors
- if (t.Methods.Count (m => m.IsConstructor) == 0)
+ if (t.GetMethods ().Count (m => m.IsConstructor) == 0)
return true;
- bool isProtectedAllowed = currentType != null ? currentType.IsDerivedFrom (t, ctx) : false;
- return t.Methods.Any (m => m.IsConstructor && lookup.IsAccessible (m, isProtectedAllowed));
+ bool isProtectedAllowed = currentType != null ? currentType.Resolve (ctx).GetDefinition ().IsDerivedFrom (t.GetDefinition ()) : false;
+ return t.GetMethods ().Any (m => m.IsConstructor && lookup.IsAccessible (m, isProtectedAllowed));
};
DefaultCompletionString = GetShortType (hintType, GetState ());
wrapper.AddType (hintType, DefaultCompletionString);
@@ -1118,7 +1117,7 @@ IEnumerable<ICompletionData> CreateTypeCompletionData (IType hintType, AstType h
return wrapper.Result;
}
- IEnumerable<ICompletionData> GetOverrideCompletionData (ITypeDefinition type, string modifiers)
+ IEnumerable<ICompletionData> GetOverrideCompletionData (IUnresolvedTypeDefinition type, string modifiers)
{
var wrapper = new CompletionDataWrapper (this);
var alreadyInserted = new Dictionary<string, bool> ();
@@ -1140,19 +1139,19 @@ IEnumerable<ICompletionData> GetOverrideCompletionData (ITypeDefinition type, st
return null; // don't add override completion for static members
}
}
- foreach (var baseType in type.GetAllBaseTypeDefinitions (ctx)) {
- AddVirtuals (alreadyInserted, wrapper, type, modifiers, baseType, declarationBegin);
+ foreach (var baseType in type.Resolve (ctx).GetAllBaseTypeDefinitions ()) {
+ AddVirtuals (alreadyInserted, wrapper, type.Resolve (ctx).GetDefinition (), modifiers, baseType, declarationBegin);
addedVirtuals = true;
}
if (!addedVirtuals)
- AddVirtuals (alreadyInserted, wrapper, type, modifiers, ctx.GetTypeDefinition (typeof(object)), declarationBegin);
+ AddVirtuals (alreadyInserted, wrapper, type.Resolve (ctx).GetDefinition (), modifiers, ProjectContent.CreateCompilation ().MainAssembly.GetTypeDefinition ("System", "Object", 0), declarationBegin);
return wrapper.Result;
}
- IEnumerable<ICompletionData> GetPartialCompletionData (ITypeDefinition type, string modifiers)
+ IEnumerable<ICompletionData> GetPartialCompletionData (IUnresolvedTypeDefinition type, string modifiers)
{
var wrapper = new CompletionDataWrapper (this);
- var partialType = GetTypeFromContext (type);
+ var partialType = type.Resolve (ctx);
if (partialType != null) {
int declarationBegin = offset;
int j = declarationBegin;
@@ -1173,12 +1172,11 @@ IEnumerable<ICompletionData> GetPartialCompletionData (ITypeDefinition type, str
var methods = new List<IMethod> ();
// gather all partial methods without implementation
- foreach (var part in partialType.GetParts ())
- foreach (var method in part.Methods) {
- if (method.IsPartial && method.BodyRegion.IsEmpty) {
- methods.Add (method);
- }
+/* TODO: foreach (var method in partialType.GetMethods ()) {
+ if (method.IsPartial && method.BodyRegion.IsEmpty) {
+ methods.Add (method);
}
+ }
// now filter all methods that are implemented in the compound class
foreach (var part in partialType.GetParts ()) {
@@ -1194,7 +1192,8 @@ IEnumerable<ICompletionData> GetPartialCompletionData (ITypeDefinition type, str
}
}
}
-
+ */
+
foreach (var method in methods) {
wrapper.Add (factory.CreateNewOverrideCompletionData (declarationBegin, type, method));
}
@@ -1209,7 +1208,7 @@ IMethod GetImplementation (ITypeDefinition type, IMethod method)
if (cur.Name == method.Name && cur.Parameters.Count == method.Parameters.Count && !cur.BodyRegion.IsEmpty) {
bool equal = true;
for (int i = 0; i < cur.Parameters.Count; i++) {
- if (!cur.Parameters [i].Type.Resolve (ctx).Equals (method.Parameters [i].Type.Resolve (ctx))) {
+ if (!cur.Parameters [i].Type.Equals (method.Parameters [i].Type)) {
equal = false;
break;
}
@@ -1240,7 +1239,7 @@ void AddVirtuals (Dictionary<string, bool> alreadyInserted, CompletionDataWrappe
if (m is IMethod && m.Name == "Finalize")
continue;
- var data = factory.CreateNewOverrideCompletionData (declarationBegin, type, m);
+ var data = factory.CreateNewOverrideCompletionData (declarationBegin, type.Parts.First (), m);
string text = GetNameWithParamCount (m);
// check if the member is already implemented
@@ -1291,14 +1290,14 @@ public string GetPreviousMemberReferenceExpression (int tokenIndex)
return result;
}
- bool MatchDelegate (IType delegateType, IMethod method)
+ bool MatchDelegate (IType delegateType, IUnresolvedMethod method)
{
var delegateMethod = delegateType.GetDelegateInvokeMethod ();
if (delegateMethod == null || delegateMethod.Parameters.Count != method.Parameters.Count)
return false;
for (int i = 0; i < delegateMethod.Parameters.Count; i++) {
- if (!delegateMethod.Parameters [i].Type.Resolve (ctx).Equals (method.Parameters [i].Type.Resolve (ctx)))
+ if (!delegateMethod.Parameters [i].Type.Equals (method.Parameters [i].Type.Resolve (ctx)))
return false;
}
return true;
@@ -1319,7 +1318,7 @@ string AddDelegateHandlers (CompletionDataWrapper completionList, IType delegate
sb.Append (", ");
sbWithoutTypes.Append (", ");
}
- var parameterType = delegateMethod.Parameters [k].Type.Resolve (ctx);
+ var parameterType = delegateMethod.Parameters [k].Type;
sb.Append (GetShortType (parameterType, GetState ()));
sb.Append (" ");
sb.Append (delegateMethod.Parameters [k].Name);
@@ -1363,11 +1362,12 @@ bool IsAccessibleFrom (IEntity member, ITypeDefinition calledType, IMember curre
if (member.IsInternal || member.IsProtectedAndInternal || member.IsProtectedOrInternal) {
var type1 = member is ITypeDefinition ? (ITypeDefinition)member : member.DeclaringTypeDefinition;
var type2 = currentMember is ITypeDefinition ? (ITypeDefinition)currentMember : currentMember.DeclaringTypeDefinition;
- bool result;
+ bool result = true;
// easy case, projects are the same
- if (type1.ProjectContent == type2.ProjectContent) {
- result = true;
- } else if (type1.ProjectContent != null) {
+/*// if (type1.ProjectContent == type2.ProjectContent) {
+// result = true;
+// } else
+ if (type1.ProjectContent != null) {
// maybe type2 hasn't project dom set (may occur in some cases), check if the file is in the project
//TODO !!
// result = type1.ProjectContent.Annotation<MonoDevelop.Projects.Project> ().GetProjectFile (type2.Region.FileName) != null;
@@ -1379,7 +1379,7 @@ bool IsAccessibleFrom (IEntity member, ITypeDefinition calledType, IMember curre
} else {
// should never happen !
result = true;
- }
+ }*/
return member.IsProtectedAndInternal ? includeProtected && result : result;
}
@@ -1403,7 +1403,7 @@ IEnumerable<ICompletionData> CreateTypeAndNamespaceCompletionData (TextLocation
if (resolveResult == null || resolveResult.IsError)
return null;
var result = new CompletionDataWrapper (this);
-
+/* TODO:
if (resolveResult is NamespaceResolveResult) {
var nr = (NamespaceResolveResult)resolveResult;
foreach (var cl in ctx.GetTypes (nr.NamespaceName, StringComparer.Ordinal)) {
@@ -1417,35 +1417,22 @@ IEnumerable<ICompletionData> CreateTypeAndNamespaceCompletionData (TextLocation
foreach (var nested in type.GetNestedTypes (ctx)) {
result.AddType (nested, nested.Name);
}
- }
+ }*/
return result.Result;
}
IEnumerable<ICompletionData> CreateTypeList ()
{
- foreach (var cl in ctx.GetTypes ("", StringComparer.Ordinal)) {
+ var compilation = ProjectContent.CreateCompilation ();
+ foreach (var cl in compilation.RootNamespace.Types) {
yield return factory.CreateTypeCompletionData (cl, cl.Name);
}
- foreach (var ns in ctx.GetNamespaces ()) {
- string name = ns;
- int idx = name.IndexOf (".");
- if (idx >= 0)
- name = name.Substring (0, idx);
- yield return factory.CreateNamespaceCompletionData (name);
+
+ foreach (var ns in compilation.RootNamespace.ChildNamespaces) {
+ yield return factory.CreateNamespaceCompletionData (ns.Name);
}
}
- public ITypeDefinition GetTypeFromContext (ITypeDefinition type)
- {
- if (type == null || type.DeclaringType != null)
- return type;
- var result = ctx.GetTypeDefinition (type.Namespace, type.Name, type.TypeParameterCount, StringComparer.Ordinal) ?? type;
- if (result.GetParts ().Count == 1)
- return type;
-// Console.WriteLine ("result:"+ result);
- return result;
- }
-
IEnumerable<ICompletionData> CreateParameterCompletion (MethodGroupResolveResult resolveResult, CSharpResolver state, AstNode invocation, int parameter, bool controlSpace)
{
var result = new CompletionDataWrapper (this);
@@ -1455,7 +1442,7 @@ IEnumerable<ICompletionData> CreateParameterCompletion (MethodGroupResolveResult
foreach (var method in resolveResult.Methods) {
if (method.Parameters.Count <= parameter)
continue;
- var resolvedType = method.Parameters [parameter].Type.Resolve (ctx);
+ var resolvedType = method.Parameters [parameter].Type;
if (resolvedType.Kind == TypeKind.Enum) {
if (addedEnums.Contains (resolvedType.ReflectionName))
continue;
@@ -1507,7 +1494,7 @@ void AddEnumMembers (CompletionDataWrapper completionList, IType resolvedType, C
string typeString = GetShortType (resolvedType, state);
if (typeString.Contains ("."))
completionList.AddType (resolvedType, typeString);
- foreach (var field in resolvedType.GetFields (ctx)) {
+ foreach (var field in resolvedType.GetFields ()) {
if (field.IsConst || field.IsStatic)
completionList.Result.Add (factory.CreateEntityCompletionData (field, typeString + "." + field.Name));
}
@@ -1521,37 +1508,37 @@ IEnumerable<ICompletionData> CreateCompletionData (TextLocation location, Resolv
if (resolveResult is NamespaceResolveResult) {
var nr = (NamespaceResolveResult)resolveResult;
var namespaceContents = new CompletionDataWrapper (this);
- foreach (var cl in ctx.GetTypes (nr.NamespaceName, StringComparer.Ordinal)) {
+/*TODO: foreach (var cl in ctx.GetTypes (nr.NamespaceName, StringComparer.Ordinal)) {
namespaceContents.AddType (cl, cl.Name);
}
foreach (var ns in ctx.GetNamespaces ().Where (n => n.Length > nr.NamespaceName.Length && n.StartsWith (nr.NamespaceName))) {
namespaceContents.AddNamespace (nr.NamespaceName, ns);
}
-
+ */
return namespaceContents.Result;
}
- IType type = GetTypeFromContext (resolveResult.Type.GetDefinition ()) ?? resolveResult.Type;
+ IType type = resolveResult.Type;
var typeDef = resolveResult.Type.GetDefinition ();
- var lookup = new MemberLookup (ctx, currentType, ProjectContent);
+ var lookup = new MemberLookup (typeDef, ProjectContent.CreateCompilation ().MainAssembly);
var result = new CompletionDataWrapper (this);
bool isProtectedAllowed = false;
bool includeStaticMembers = false;
if (resolveResult is LocalResolveResult) {
- isProtectedAllowed = currentType != null && typeDef != null ? typeDef.GetAllBaseTypeDefinitions (ctx).Any (bt => bt.Equals (currentType)) : false;
+ isProtectedAllowed = currentType != null && typeDef != null ? typeDef.GetAllBaseTypeDefinitions ().Any (bt => bt.Equals (currentType)) : false;
if (resolvedNode is IdentifierExpression) {
var mrr = (LocalResolveResult)resolveResult;
includeStaticMembers = mrr.Variable.Name == mrr.Type.Name;
}
} else {
- isProtectedAllowed = currentType != null && typeDef != null ? currentType.GetAllBaseTypeDefinitions (ctx).Any (bt => bt.Equals (typeDef)) : false;
+ isProtectedAllowed = currentType != null && typeDef != null ? currentType.Resolve (ctx).GetDefinition ().GetAllBaseTypeDefinitions ().Any (bt => bt.Equals (typeDef)) : false;
}
if (resolveResult is TypeResolveResult && type.Kind == TypeKind.Enum) {
- foreach (var field in type.GetFields (ctx)) {
+ foreach (var field in type.GetFields ()) {
result.AddMember (field);
}
- foreach (var m in type.GetMethods (ctx)) {
+ foreach (var m in type.GetMethods ()) {
if (m.Name == "TryParse")
result.AddMember (m);
}
@@ -1568,7 +1555,7 @@ IEnumerable<ICompletionData> CreateCompletionData (TextLocation location, Resolv
// Console.WriteLine (resolveResult);
// Console.WriteLine (currentMember != null ? currentMember.IsStatic : "currentMember == null");
if (resolvedNode.Annotation<ObjectCreateExpression> () == null) { //tags the created expression as part of an object create expression.
- foreach (var member in type.GetMembers (ctx)) {
+ foreach (var member in type.GetMembers ()) {
if (!lookup.IsAccessible (member, isProtectedAllowed)) {
// Console.WriteLine ("skip access: " + member.FullName);
continue;
@@ -1590,20 +1577,17 @@ IEnumerable<ICompletionData> CreateCompletionData (TextLocation location, Resolv
}
if (resolveResult is TypeResolveResult || includeStaticMembers) {
- foreach (var nested in type.GetNestedTypes (ctx)) {
+ foreach (var nested in type.GetNestedTypes ()) {
result.AddType (nested, nested.Name);
}
} else {
- var baseTypes = new List<IType> (type.GetAllBaseTypes (ctx));
- var conv = new Conversions (ctx);
+ var baseTypes = new List<IType> (type.GetAllBaseTypes ());
+ var conv = new Conversions (ProjectContent.CreateCompilation ());
for (var n = state.CurrentUsingScope; n != null; n = n.Parent) {
- AddExtensionMethods (result, conv, baseTypes, n.NamespaceName);
+ AddExtensionMethods (result, conv, baseTypes, n.Namespace.FullName);
foreach (var u in n.Usings) {
- var ns = u.ResolveNamespace (ctx);
- if (ns == null)
- continue;
- AddExtensionMethods (result, conv, baseTypes, ns.NamespaceName);
+ AddExtensionMethods (result, conv, baseTypes, u.FullName);
}
}
}
@@ -1634,6 +1618,7 @@ IEnumerable<ICompletionData> CreateCompletionData (TextLocation location, Resolv
void AddExtensionMethods (CompletionDataWrapper result, Conversions conv, List<IType> baseTypes, string namespaceName)
{
+ /* TODO:
foreach (var typeDefinition in ctx.GetTypes (namespaceName, StringComparer.Ordinal).Where (t => t.IsStatic && t.HasExtensionMethods)) {
foreach (var m in typeDefinition.Methods.Where (m => m.IsExtensionMethod )) {
var pt = m.Parameters.First ().Type.Resolve (ctx);
@@ -1642,7 +1627,7 @@ void AddExtensionMethods (CompletionDataWrapper result, Conversions conv, List<I
result.AddMember (m);
}
}
- }
+ }*/
}
IEnumerable<ICompletionData> CreateCaseCompletionData (TextLocation location)
@@ -1738,7 +1723,7 @@ IEnumerable<ICompletionData> CreateCaseCompletionData (TextLocation location)
var member2 = baseUnit.GetNodeAt<AttributedNode> (memberLocation);
member2.Remove ();
member.ReplaceWith (member2);
- var tsvisitor = new TypeSystemConvertVisitor (ProjectContent, this.CSharpParsedFile.FileName);
+ var tsvisitor = new TypeSystemConvertVisitor (this.CSharpParsedFile.FileName);
Unit.AcceptVisitor (tsvisitor, null);
return Tuple.Create (tsvisitor.ParsedFile, (AstNode)expr, Unit);
}
@@ -1811,11 +1796,11 @@ IEnumerable<ICompletionData> CreateCaseCompletionData (TextLocation location)
member.ReplaceWith (member2);
}
} else {
- var tsvisitor2 = new TypeSystemConvertVisitor (ProjectContent, CSharpParsedFile.FileName);
+ var tsvisitor2 = new TypeSystemConvertVisitor (CSharpParsedFile.FileName);
Unit.AcceptVisitor (tsvisitor2, null);
return Tuple.Create (tsvisitor2.ParsedFile, expr, baseUnit);
}
- var tsvisitor = new TypeSystemConvertVisitor (ProjectContent, CSharpParsedFile.FileName);
+ var tsvisitor = new TypeSystemConvertVisitor (CSharpParsedFile.FileName);
Unit.AcceptVisitor (tsvisitor, null);
return Tuple.Create (tsvisitor.ParsedFile, expr, Unit);
}
@@ -1828,14 +1813,14 @@ IEnumerable<ICompletionData> CreateCaseCompletionData (TextLocation location)
sb.Append ("a;");
AppendMissingClosingBrackets (sb, text, false);
var stream = new System.IO.StringReader (sb.ToString ());
- var completionUnit = parser.Parse (stream, 0);
+ var completionUnit = parser.Parse (stream, CSharpParsedFile.FileName, 0);
stream.Close ();
var loc = document.GetLocation (offset);
var expr = completionUnit.GetNodeAt (loc, n => n is Expression || n is VariableDeclarationStatement);
if (expr == null)
return null;
- var tsvisitor = new TypeSystemConvertVisitor (ProjectContent, CSharpParsedFile.FileName);
+ var tsvisitor = new TypeSystemConvertVisitor (CSharpParsedFile.FileName);
completionUnit.AcceptVisitor (tsvisitor, null);
return Tuple.Create (tsvisitor.ParsedFile, expr, completionUnit);
@@ -1849,14 +1834,14 @@ IEnumerable<ICompletionData> CreateCaseCompletionData (TextLocation location)
sb.Append ("a ();");
AppendMissingClosingBrackets (sb, text, false);
var stream = new System.IO.StringReader (sb.ToString ());
- var completionUnit = parser.Parse (stream, 0);
+ var completionUnit = parser.Parse (stream, CSharpParsedFile.FileName, 0);
stream.Close ();
var loc = document.GetLocation (offset);
var expr = completionUnit.GetNodeAt (loc, n => n is Expression);
if (expr == null)
return null;
- var tsvisitor = new TypeSystemConvertVisitor (ProjectContent, CSharpParsedFile.FileName);
+ var tsvisitor = new TypeSystemConvertVisitor (CSharpParsedFile.FileName);
completionUnit.AcceptVisitor (tsvisitor, null);
return Tuple.Create (tsvisitor.ParsedFile, expr, completionUnit);
@@ -1900,7 +1885,7 @@ bool GetParameterCompletionCommandOffset (out int cpos)
// Start calculating the parameter offset from the beginning of the
// current member, instead of the beginning of the file.
cpos = offset - 1;
- IMember mem = currentMember;
+ var mem = currentMember;
if (mem == null || (mem is IType))
return false;
int startPos = document.GetOffset (mem.Region.BeginLine, mem.Region.BeginColumn);
@@ -2003,7 +1988,8 @@ int GetCurrentParameterIndex (int offset, int memberStart)
CSharpResolver GetState ()
{
- var state = new CSharpResolver (ctx, System.Threading.CancellationToken.None);
+ return new CSharpResolver (ctx);
+ /*var state = new CSharpResolver (ctx);
state.CurrentMember = currentMember;
state.CurrentTypeDefinition = currentType;
@@ -2023,7 +2009,7 @@ CSharpResolver GetState ()
}
}
- return state;
+ return state;*/
}
#endregion
View
17 ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs
@@ -34,6 +34,7 @@
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
+using ICSharpCode.NRefactory.CSharp.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp.Completion
{
@@ -45,11 +46,11 @@ public class CSharpCompletionEngineBase
protected IDocument document;
protected int offset;
protected TextLocation location;
- protected ITypeDefinition currentType;
- protected IMember currentMember;
+ protected IUnresolvedTypeDefinition currentType;
+ protected IUnresolvedMember currentMember;
#region Input properties
- public ITypeResolveContext ctx { get; set; }
+ public CSharpTypeResolveContext ctx { get; set; }
public CompilationUnit Unit { get; set; }
@@ -322,7 +323,7 @@ protected CompilationUnit ParseStub (string continuation, bool appendSemicolon =
using (var stream = new System.IO.StringReader (wrapper.ToString ())) {
try {
var parser = new CSharpParser ();
- return parser.Parse (stream, wrapInClass ? memberLocation.Line - 2 : 0);
+ return parser.Parse (stream, "stub.cs" , wrapInClass ? memberLocation.Line - 2 : 0);
} catch (Exception){
Console.WriteLine ("------");
Console.WriteLine (wrapper);
@@ -460,17 +461,15 @@ protected virtual void Reset ()
resolveNode = expr;
}
- var csResolver = new CSharpResolver (ctx, System.Threading.CancellationToken.None);
+ var csResolver = new CSharpResolver (ctx);
var navigator = new NodeListResolveVisitorNavigator (new[] { resolveNode });
- if (ProjectContent is SimpleProjectContent)
- ((SimpleProjectContent)ProjectContent).UpdateProjectContent (CSharpParsedFile, file);
+ ProjectContent.UpdateProjectContent (CSharpParsedFile, file);
var visitor = new ResolveVisitor (csResolver, file, navigator);
visitor.Scan (unit);
var state = visitor.GetResolverStateBefore (resolveNode);
var result = visitor.GetResolveResult (resolveNode);
- if (ProjectContent is SimpleProjectContent)
- ((SimpleProjectContent)ProjectContent).UpdateProjectContent (file, CSharpParsedFile);
+ ProjectContent.UpdateProjectContent (file, CSharpParsedFile);
return Tuple.Create (result, state);
}
View
9 ICSharpCode.NRefactory.CSharp/Completion/CSharpParameterCompletionEngine.cs
@@ -30,6 +30,7 @@
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.CSharp.Resolver;
+using ICSharpCode.NRefactory.CSharp.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp.Completion
{
@@ -64,7 +65,7 @@ public CSharpParameterCompletionEngine (IDocument document, IParameterCompletion
var member2 = baseUnit.GetNodeAt<AttributedNode> (memberLocation);
member2.Remove ();
member.ReplaceWith (member2);
- var tsvisitor = new TypeSystemConvertVisitor (ProjectContent, CSharpParsedFile.FileName);
+ var tsvisitor = new TypeSystemConvertVisitor (CSharpParsedFile.FileName);
Unit.AcceptVisitor (tsvisitor, null);
return Tuple.Create (tsvisitor.ParsedFile, (AstNode)expr, Unit);
}
@@ -175,13 +176,15 @@ List<string> GetUsedNamespaces ()
{
var scope = CSharpParsedFile.GetUsingScope (location);
var result = new List<string> ();
+ var resolver = new CSharpResolver (ctx);
while (scope != null) {
result.Add (scope.NamespaceName);
+
foreach (var u in scope.Usings) {
- var ns = u.ResolveNamespace (ctx);
+ var ns = u.ResolveNamespace (resolver);
if (ns == null)
continue;
- result.Add (ns.NamespaceName);
+ result.Add (ns.FullName);
}
scope = scope.Parent;
}
View
55 ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs
@@ -93,6 +93,14 @@ public void AddType (IType type, string shortType)
usedTypes.Add (shortType);
result.Add (Factory.CreateTypeCompletionData (type, shortType));
}
+
+ public void AddType (IUnresolvedTypeDefinition type, string shortType)
+ {
+ if (type == null || string.IsNullOrEmpty (shortType) || usedTypes.Contains (shortType))
+ return;
+ usedTypes.Add (shortType);
+ result.Add (Factory.CreateTypeCompletionData (type, shortType));
+ }
Dictionary<string, List<ICompletionData>> data = new Dictionary<string, List<ICompletionData>> ();
@@ -104,7 +112,7 @@ public void AddVariable (IVariable variable)
result.Add (Factory.CreateVariableCompletionData (variable));
}
- public void AddTypeParameter (ITypeParameter variable)
+ public void AddTypeParameter (IUnresolvedTypeParameter variable)
{
if (data.ContainsKey (variable.Name))
return;
@@ -112,6 +120,43 @@ public void AddTypeParameter (ITypeParameter variable)
result.Add (Factory.CreateVariableCompletionData (variable));
}
+ public ICompletionData AddMember (IUnresolvedMember member)
+ {
+ var newData = Factory.CreateEntityCompletionData (member);
+
+// newData.HideExtensionParameter = HideExtensionParameter;
+ string memberKey = newData.DisplayText;
+ if (memberKey == null)
+ return null;
+ if (member is IMember) {
+ newData.CompletionCategory = GetCompletionCategory (member.DeclaringTypeDefinition.Resolve (completion.ctx));
+ }
+ List<ICompletionData> existingData;
+ data.TryGetValue (memberKey, out existingData);
+
+ if (existingData != null) {
+ var a = member as IEntity;
+ foreach (var d in existingData) {
+ if (!(d is IEntityCompletionData))
+ continue;
+ var b = ((IEntityCompletionData)d).Entity;
+ if (a == null || b == null || a.EntityType == b.EntityType) {
+ d.AddOverload (newData);
+ return d;
+ }
+ }
+ if (newData != null) {
+ result.Add (newData);
+ data [memberKey].Add (newData);
+ }
+ } else {
+ result.Add (newData);
+ data [memberKey] = new List<ICompletionData> ();
+ data [memberKey].Add (newData);
+ }
+ return newData;
+ }
+
public ICompletionData AddMember (IMember member)
{
var newData = Factory.CreateEntityCompletionData (member);
@@ -149,7 +194,7 @@ public ICompletionData AddMember (IMember member)
return newData;
}
- internal CompletionCategory GetCompletionCategory (ITypeDefinition type)
+ internal CompletionCategory GetCompletionCategory (IType type)
{
if (type == null)
return null;
@@ -158,15 +203,15 @@ internal CompletionCategory GetCompletionCategory (ITypeDefinition type)
return completionCategories [type];
}
- Dictionary<ITypeDefinition, CompletionCategory> completionCategories = new Dictionary<ITypeDefinition, CompletionCategory> ();
+ Dictionary<IType, CompletionCategory> completionCategories = new Dictionary<IType, CompletionCategory> ();
class TypeCompletionCategory : CompletionCategory
{
- public ITypeDefinition Type {
+ public IType Type {
get;
private set;
}
- public TypeCompletionCategory (ITypeDefinition type) : base (type.FullName, null)
+ public TypeCompletionCategory (IType type) : base (type.FullName, null)
{
this.Type = type;
}
View
10 ICSharpCode.NRefactory.CSharp/Completion/ICompletionDataFactory.cs
@@ -32,11 +32,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
{
public interface ICompletionDataFactory
{
+ ICompletionData CreateEntityCompletionData (IUnresolvedEntity entity);
+ ICompletionData CreateEntityCompletionData (IUnresolvedEntity entity, string text);
ICompletionData CreateEntityCompletionData (IEntity entity);
-
ICompletionData CreateEntityCompletionData (IEntity entity, string text);
ICompletionData CreateTypeCompletionData (IType type, string shortType);
+ ICompletionData CreateTypeCompletionData (IUnresolvedTypeDefinition type, string shortType);
/// <summary>
/// Creates a generic completion data.
@@ -56,11 +58,11 @@ public interface ICompletionDataFactory
ICompletionData CreateVariableCompletionData (IVariable variable);
- ICompletionData CreateVariableCompletionData (ITypeParameter parameter);
+ ICompletionData CreateVariableCompletionData (IUnresolvedTypeParameter parameter);
- ICompletionData CreateEventCreationCompletionData (string varName, IType delegateType, IEvent evt, string parameterDefinition, IMember currentMember, ITypeDefinition currentType);
+ ICompletionData CreateEventCreationCompletionData (string varName, IType delegateType, IEvent evt, string parameterDefinition, IUnresolvedMember currentMember, IUnresolvedTypeDefinition currentType);
- ICompletionData CreateNewOverrideCompletionData (int declarationBegin, ITypeDefinition type, IMember m);
+ ICompletionData CreateNewOverrideCompletionData (int declarationBegin, IUnresolvedTypeDefinition type, IMember m);
IEnumerable<ICompletionData> CreateCodeTemplateCompletionData ();
View
5 ICSharpCode.NRefactory.CSharp/ICSharpCode.NRefactory.CSharp.csproj
@@ -312,6 +312,10 @@
<Compile Include="TypeSystem\UsingScope.cs" />
<Compile Include="Ast\GeneralScope\PreProcessorDirective.cs" />
<Compile Include="Ast\Expressions\ErrorExpression.cs" />
+ <Compile Include="Completion\CompletionDataWrapper.cs" />
+ <Compile Include="Completion\CSharpCompletionEngine.cs" />
+ <Compile Include="Completion\CSharpCompletionEngineBase.cs" />
+ <Compile Include="Completion\CSharpParameterCompletionEngine.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
@@ -322,7 +326,6 @@
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Folder Include="Completion\" />
- <Folder Include="TypeSystem" />
</ItemGroup>
<ProjectExtensions>
<MonoDevelop>
View
47 ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs
@@ -39,6 +39,7 @@
using ICSharpCode.NRefactory.Editor;
using System.Diagnostics;
using System.Text;
+using ICSharpCode.NRefactory.CSharp.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp.CodeCompletion
@@ -133,6 +134,21 @@ public ICompletionData CreateEntityCompletionData (ICSharpCode.NRefactory.TypeSy
return new CompletionData (text);
}
+ public ICompletionData CreateEntityCompletionData (ICSharpCode.NRefactory.TypeSystem.IUnresolvedEntity entity)
+ {
+ return new CompletionData (entity.Name);
+ }
+
+ public ICompletionData CreateEntityCompletionData (ICSharpCode.NRefactory.TypeSystem.IUnresolvedEntity entity, string text)
+ {
+ return new CompletionData (text);
+ }
+
+ public ICompletionData CreateTypeCompletionData (ICSharpCode.NRefactory.TypeSystem.IUnresolvedTypeDefinition type, string shortType)
+ {
+ return new CompletionData (shortType);
+ }
+
public ICompletionData CreateTypeCompletionData (ICSharpCode.NRefactory.TypeSystem.IType type, string shortType)
{
return new CompletionData (shortType);
@@ -153,17 +169,17 @@ public ICompletionData CreateVariableCompletionData (ICSharpCode.NRefactory.Type
return new CompletionData (variable.Name);
}
- public ICompletionData CreateVariableCompletionData (ICSharpCode.NRefactory.TypeSystem.ITypeParameter parameter)
+ public ICompletionData CreateVariableCompletionData (ICSharpCode.NRefactory.TypeSystem.IUnresolvedTypeParameter parameter)
{
return new CompletionData (parameter.Name);
}
- public ICompletionData CreateEventCreationCompletionData (string varName, ICSharpCode.NRefactory.TypeSystem.IType delegateType, ICSharpCode.NRefactory.TypeSystem.IEvent evt, string parameterDefinition, ICSharpCode.NRefactory.TypeSystem.IMember currentMember, ICSharpCode.NRefactory.TypeSystem.ITypeDefinition currentType)
+ public ICompletionData CreateEventCreationCompletionData (string varName, ICSharpCode.NRefactory.TypeSystem.IType delegateType, ICSharpCode.NRefactory.TypeSystem.IEvent evt, string parameterDefinition, ICSharpCode.NRefactory.TypeSystem.IUnresolvedMember currentMember, ICSharpCode.NRefactory.TypeSystem.IUnresolvedTypeDefinition currentType)
{
return new CompletionData (varName);
}
- public ICompletionData CreateNewOverrideCompletionData (int declarationBegin, ICSharpCode.NRefactory.TypeSystem.ITypeDefinition type, ICSharpCode.NRefactory.TypeSystem.IMember m)
+ public ICompletionData CreateNewOverrideCompletionData (int declarationBegin, ICSharpCode.NRefactory.TypeSystem.IUnresolvedTypeDefinition type, ICSharpCode.NRefactory.TypeSystem.IMember m)
{
return new CompletionData (m.Name);
}
@@ -197,15 +213,16 @@ static CompletionDataList CreateProvider (string text, bool isCtrlSpace)
var doc = new ReadOnlyDocument (editorText);
var engine = new CSharpCompletionEngine (doc, new TestFactory ());
- var pctx = new SimpleProjectContent ();
+ var pctx = new CSharpProjectContent ();
+ pctx.AddAssemblyReferences (new [] { CecilLoaderTests.Mscorlib, CecilLoaderTests.SystemCore });
- var compilationUnit = new CSharpParser ().Parse (parsedText);
+ var compilationUnit = new CSharpParser ().Parse (parsedText, "program.cs");
- var parsedFile = new TypeSystemConvertVisitor (pctx, "program.cs").Convert (compilationUnit);
+ var parsedFile = compilationUnit.ToTypeSystem ();
pctx.UpdateProjectContent (null, parsedFile);
-
- var ctx = new CompositeTypeResolveContext ( new [] { pctx, CecilLoaderTests.Mscorlib, CecilLoaderTests.SystemCore });
- engine.ctx = ctx;
+ var cmp = pctx.CreateCompilation ();
+
+ engine.ctx = new CSharpTypeResolveContext (cmp.MainAssembly);
engine.EolMarker = Environment.NewLine;
engine.FormattingPolicy = new CSharpFormattingOptions ();
engine.CSharpParsedFile = parsedFile;
@@ -225,13 +242,15 @@ static CompletionDataList CreateProvider (string text, bool isCtrlSpace)
Tuple<ReadOnlyDocument, CSharpCompletionEngine> GetContent (string text, CompilationUnit compilationUnit)
{
var doc = new ReadOnlyDocument (text);
- var pctx = new SimpleProjectContent ();
- var parsedFile = new TypeSystemConvertVisitor (pctx, "program.cs").Convert (compilationUnit);
+ var pctx = new CSharpProjectContent ();
+ var parsedFile = compilationUnit.ToTypeSystem ();
pctx.UpdateProjectContent (null, parsedFile);
+ pctx.AddAssemblyReferences (new [] { CecilLoaderTests.Mscorlib, CecilLoaderTests.SystemCore });
+ var cmp = pctx.CreateCompilation ();
+
var engine = new CSharpCompletionEngine (doc, new TestFactory ());
- var ctx = new CompositeTypeResolveContext ( new [] { pctx, CecilLoaderTests.Mscorlib, CecilLoaderTests.SystemCore });
- engine.ctx = ctx;
+ engine.ctx = new CSharpTypeResolveContext (cmp.MainAssembly);
engine.EolMarker = Environment.NewLine;
engine.FormattingPolicy = new CSharpFormattingOptions ();
engine.CSharpParsedFile = parsedFile;
@@ -306,7 +325,7 @@ public void TestLoadAllTests ()
continue;
var text = File.ReadAllText (file, Encoding.Default);
try {
- var unit = new CSharpParser ().Parse (text);
+ var unit = new CSharpParser ().Parse (text, file);
var cnt = GetContent (text, unit);
View
23 ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/ParameterCompletionTests.cs
@@ -35,6 +35,7 @@
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using ICSharpCode.NRefactory.TypeSystem;
using System.Linq;
+using ICSharpCode.NRefactory.CSharp.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp.CodeCompletion
{
@@ -43,9 +44,9 @@ public class ParameterCompletionTests : TestBase
{
class TestFactory : IParameterCompletionDataFactory
{
- ITypeResolveContext ctx;
+ IProjectContent ctx;
- public TestFactory (ITypeResolveContext ctx)
+ public TestFactory (IProjectContent ctx)
{
this.ctx = ctx;
}
@@ -111,7 +112,7 @@ public IParameterDataProvider CreateConstructorProvider (ICSharpCode.NRefactory.
{
return new Provider () {
- Data = type.GetConstructors (ctx, m => m.Accessibility == Accessibility.Public)
+ Data = type.GetConstructors (m => m.Accessibility == Accessibility.Public)
};
}
@@ -139,7 +140,7 @@ public IParameterDataProvider CreateDelegateDataProvider (ICSharpCode.NRefactory
public IParameterDataProvider CreateIndexerParameterDataProvider (IType type, AstNode resolvedNode)
{
return new IndexerProvider () {
- Data = type.GetProperties (ctx, p => p.IsIndexer)
+ Data = type.GetProperties (p => p.IsIndexer)
};
}
#endregion
@@ -161,17 +162,17 @@ internal static IParameterDataProvider CreateProvider (string text)
var doc = new ReadOnlyDocument (editorText);
- var pctx = new SimpleProjectContent ();
+ var pctx = new CSharpProjectContent ();
+ pctx.AddAssemblyReferences (new [] { CecilLoaderTests.Mscorlib, CecilLoaderTests.SystemCore });
- var compilationUnit = new CSharpParser ().Parse (parsedText);
+ var compilationUnit = new CSharpParser ().Parse (parsedText, "program.cs");
- var parsedFile = new TypeSystemConvertVisitor (pctx, "program.cs").Convert (compilationUnit);
+ var parsedFile = compilationUnit.ToTypeSystem ();
pctx.UpdateProjectContent (null, parsedFile);
-
- var ctx = new CompositeTypeResolveContext ( new [] { pctx, CecilLoaderTests.Mscorlib, CecilLoaderTests.SystemCore });
+ var cmp = pctx.CreateCompilation ();
+ var engine = new CSharpParameterCompletionEngine (doc, new TestFactory (pctx));
- var engine = new CSharpParameterCompletionEngine (doc, new TestFactory (ctx));
- engine.ctx = ctx;
+ engine.ctx = new CSharpTypeResolveContext (cmp.MainAssembly);
engine.CSharpParsedFile = parsedFile;
engine.ProjectContent = pctx;
engine.Unit = compilationUnit;
View
15 ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{63D3B27A-D966-4902-90B3-30290E1692F1}</ProjectGuid>
@@ -192,6 +192,19 @@
<Compile Include="CSharp\ContextAction\TestRefactoringContext.cs" />
<Compile Include="CSharp\ContextAction\ContextActionTestBase.cs" />
<Compile Include="CSharp\ContextAction\UseExplicitTypeTests.cs" />
+ <Compile Include="CSharp\CodeCompletion\CodeCompletionAccessibleTests.cs" />
+ <Compile Include="CSharp\CodeCompletion\CodeCompletionBugTests.cs" />
+ <Compile Include="CSharp\CodeCompletion\CodeCompletionCSharp3Tests.cs" />
+ <Compile Include="CSharp\CodeCompletion\CodeCompletionCSharpTests.cs" />
+ <Compile Include="CSharp\CodeCompletion\CodeComplteionOperatorTests.cs" />
+ <Compile Include="CSharp\CodeCompletion\CompletionDataList.cs" />
+ <Compile Include="CSharp\CodeCompletion\EnumContextTests.cs" />
+ <Compile Include="CSharp\CodeCompletion\KeywordTests.cs" />
+ <Compile Include="CSharp\CodeCompletion\ObjectInitializerTests.cs" />
+ <Compile Include="CSharp\CodeCompletion\ParameterCompletionTests.cs" />
+ <Compile Include="CSharp\CodeCompletion\PreProcessorTests.cs" />
+ <Compile Include="CSharp\CodeCompletion\TestBase.cs" />
+ <Compile Include="CSharp\CodeCompletion\VariableDeclarationStatementTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj">
View
5 ICSharpCode.NRefactory/TypeSystem/ITypeDefinition.cs
@@ -36,6 +36,11 @@ public interface IUnresolvedTypeDefinition : ITypeReference, IUnresolvedEntity
IList<IUnresolvedTypeDefinition> NestedTypes { get; }
IList<IUnresolvedMember> Members { get; }
+ IEnumerable<IUnresolvedMethod> Methods { get; }
+ IEnumerable<IUnresolvedProperty> Properties { get; }
+ IEnumerable<IUnresolvedField> Fields { get; }
+ IEnumerable<IUnresolvedEvent> Events { get; }
+
/// <summary>
/// Gets whether the type definition contains extension methods.
/// Returns null when the type definition needs to be resolved in order to determine whether
View
26 ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeDefinition.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
+using System.Linq;
using System.Collections.Generic;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation
@@ -152,6 +153,31 @@ public DefaultUnresolvedTypeDefinition(IUnresolvedTypeDefinition declaringTypeDe
}
}
+ public IEnumerable<IUnresolvedMethod> Methods {
+ get {
+ return Members.OfType<IUnresolvedMethod> ();
+ }
+ }
+
+ public IEnumerable<IUnresolvedProperty> Properties {
+ get {
+ return Members.OfType<IUnresolvedProperty> ();
+ }
+ }
+
+ public IEnumerable<IUnresolvedField> Fields {
+ get {
+ return Members.OfType<IUnresolvedField> ();
+ }
+ }
+
+ public IEnumerable<IUnresolvedEvent> Events {
+ get {
+ return Members.OfType<IUnresolvedEvent> ();
+ }
+ }
+
+
public IType Resolve(ITypeResolveContext context)
{
if (context == null)

No commit comments for this range

Something went wrong with that request. Please try again.