|
|
|
|
@ -551,11 +551,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -551,11 +551,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (n != null && n.Parent is ObjectCreateExpression) { |
|
|
|
|
var invokeResult = ResolveExpression (n.Parent, identifierStart.Unit); |
|
|
|
|
var mgr = invokeResult != null ? invokeResult.Item1 as ResolveResult : null; |
|
|
|
|
|
|
|
|
|
if (mgr != null) { |
|
|
|
|
foreach (var constructor in mgr.Type.GetConstructors ()) { |
|
|
|
|
foreach (var p in constructor.Parameters) { |
|
|
|
|
@ -1711,18 +1709,28 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -1711,18 +1709,28 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
return n is Attribute; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
IType GuessHintType (AstNode resolvedNode) |
|
|
|
|
{ |
|
|
|
|
ObjectCreateExpression oce = resolvedNode.Parent as ObjectCreateExpression ?? (ObjectCreateExpression)resolvedNode.Ancestors.FirstOrDefault (n => n is ObjectCreateExpression); |
|
|
|
|
if (oce != null && oce.Parent is ReturnStatement) |
|
|
|
|
return ctx.CurrentMember != null ? ctx.CurrentMember.ReturnType : null; |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
IEnumerable<ICompletionData> CreateTypeAndNamespaceCompletionData (TextLocation location, ResolveResult resolveResult, AstNode resolvedNode, CSharpResolver state) |
|
|
|
|
{ |
|
|
|
|
if (resolveResult == null || resolveResult.IsError) |
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
var hintType = GuessHintType (resolvedNode); |
|
|
|
|
var result = new CompletionDataWrapper (this); |
|
|
|
|
if (resolveResult is NamespaceResolveResult) { |
|
|
|
|
var nr = (NamespaceResolveResult)resolveResult; |
|
|
|
|
if (!(resolvedNode.Parent is UsingDeclaration || resolvedNode.Parent != null && resolvedNode.Parent.Parent is UsingDeclaration)) { |
|
|
|
|
Console.WriteLine ("fooo"); |
|
|
|
|
foreach (var cl in nr.Namespace.Types) { |
|
|
|
|
string name = cl.Name; |
|
|
|
|
|
|
|
|
|
if (hintType != null && hintType.Kind != TypeKind.Array && cl.Kind == TypeKind.Interface) |
|
|
|
|
continue; |
|
|
|
|
if (IsAttributeContext (resolvedNode) && name.EndsWith ("Attribute") && name.Length > "Attribute".Length) |
|
|
|
|
name = name.Substring (0, name.Length - "Attribute".Length); |
|
|
|
|
result.AddType (cl, name); |
|
|
|
|
@ -1734,6 +1742,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -1734,6 +1742,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
} else if (resolveResult is TypeResolveResult) { |
|
|
|
|
var type = resolveResult.Type; |
|
|
|
|
foreach (var nested in type.GetNestedTypes ()) { |
|
|
|
|
if (hintType != null && hintType.Kind != TypeKind.Array && nested.Kind == TypeKind.Interface) |
|
|
|
|
continue; |
|
|
|
|
result.AddType (nested, nested.Name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -2079,7 +2089,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -2079,7 +2089,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
if (invoke != null) |
|
|
|
|
mref = invoke.Target as MemberReferenceExpression; |
|
|
|
|
} |
|
|
|
|
Expression expr = null; |
|
|
|
|
AstNode expr = null; |
|
|
|
|
if (mref != null) { |
|
|
|
|
expr = mref.Target.Clone (); |
|
|
|
|
mref.Parent.ReplaceWith (expr); |
|
|
|
|
@ -2089,29 +2099,38 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -2089,29 +2099,38 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
if (memberType == null) { |
|
|
|
|
memberType = baseUnit.GetNodeAt<MemberType> (location); |
|
|
|
|
if (memberType != null) { |
|
|
|
|
if (memberType.Parent is ObjectCreateExpression) { |
|
|
|
|
var mt = memberType.Target.Clone (); |
|
|
|
|
memberType.ReplaceWith (mt); |
|
|
|
|
expr = mt; |
|
|
|
|
goto exit; |
|
|
|
|
} else { |
|
|
|
|
tref = baseUnit.GetNodeAt<Expression> (location); |
|
|
|
|
if (tref == null) { |
|
|
|
|
tref = new TypeReferenceExpression (memberType.Clone ()); |
|
|
|
|
memberType.Parent.AddChild (tref, AstNode.Roles.Expression); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (tref is ObjectCreateExpression) { |
|
|
|
|
expr = new TypeReferenceExpression (memberType.Target.Clone ()); |
|
|
|
|
expr.AddAnnotation (new ObjectCreateExpression ()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (memberType == null) |
|
|
|
|
return null; |
|
|
|
|
if (expr == null) |
|
|
|
|
if (expr == null) { |
|
|
|
|
expr = new TypeReferenceExpression (memberType.Target.Clone ()); |
|
|
|
|
} |
|
|
|
|
tref.ReplaceWith (expr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
exit: |
|
|
|
|
var member = Unit.GetNodeAt<EntityDeclaration> (memberLocation); |
|
|
|
|
var member2 = baseUnit.GetNodeAt<EntityDeclaration> (memberLocation); |
|
|
|
|
member2.Remove (); |
|
|
|
|
member.ReplaceWith (member2); |
|
|
|
|
Print (member2); |
|
|
|
|
return new ExpressionResult ((AstNode)expr, Unit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -2145,6 +2164,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -2145,6 +2164,9 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
if (expr == null) { |
|
|
|
|
baseUnit = ParseStub ("()"); |
|
|
|
|
expr = baseUnit.GetNodeAt<IdentifierExpression> (location.Line, location.Column - 1); |
|
|
|
|
if (expr == null) { |
|
|
|
|
expr = baseUnit.GetNodeAt<MemberType> (location.Line, location.Column - 1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (expr == null) { |
|
|
|
|
|