|
|
|
|
@ -1302,6 +1302,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -1302,6 +1302,13 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
if (resolved != null) |
|
|
|
|
hintType = resolved.Item1.Type; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (newParentNode is ReturnStatement) { |
|
|
|
|
var varDecl = (ReturnStatement)newParentNode; |
|
|
|
|
if (ctx.CurrentMember != null) |
|
|
|
|
hintType = ctx.CurrentMember.ReturnType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return CreateTypeCompletionData (hintType, hintTypeAst); |
|
|
|
|
// IType callingType = NRefactoryResolver.GetTypeAtCursor (Document.CompilationUnit, Document.FileName, new TextLocation (document.Caret.Line, document.Caret.Column));
|
|
|
|
|
// ExpressionContext newExactContext = new NewCSharpExpressionFinder (dom).FindExactContextForNewCompletion (document, Document.CompilationUnit, Document.FileName, callingType);
|
|
|
|
|
@ -1409,15 +1416,18 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
@@ -1409,15 +1416,18 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
|
|
|
|
|
// check if type is in inheritance tree.
|
|
|
|
|
if (hintType.GetDefinition () != null && !t.GetDefinition ().IsDerivedFrom (hintType.GetDefinition ())) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (t.Kind == TypeKind.Interface && hintType.Kind != TypeKind.Array) |
|
|
|
|
return false; |
|
|
|
|
// check for valid constructors
|
|
|
|
|
if (t.GetConstructors ().Count () == 0) |
|
|
|
|
return true; |
|
|
|
|
bool isProtectedAllowed = currentType != null ? currentType.Resolve (ctx).GetDefinition ().IsDerivedFrom (t.GetDefinition ()) : false; |
|
|
|
|
return t.GetConstructors ().Any (m => lookup.IsAccessible (m, isProtectedAllowed)); |
|
|
|
|
}; |
|
|
|
|
if (!(hintType.Kind == TypeKind.Interface && hintType.Kind != TypeKind.Array)) { |
|
|
|
|
DefaultCompletionString = GetShortType (hintType, GetState ()); |
|
|
|
|
wrapper.AddType (hintType, DefaultCompletionString); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
DefaultCompletionString = hintTypeAst.ToString (); |
|
|
|
|
wrapper.AddType (hintType, DefaultCompletionString); |
|
|
|
|
|