Browse Source

Merge 009789a500 into 17294bb067

pull/730/merge
mykolav 10 years ago
parent
commit
36dbedeb4e
  1. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionBinding.cs
  2. 25
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionContext.cs

4
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionBinding.cs

@ -129,7 +129,9 @@ namespace CSharpBinding.Completion @@ -129,7 +129,9 @@ namespace CSharpBinding.Completion
triggerWordLength = 0;
}
completionData = cce.GetCompletionData(startPos, true);
completionData = completionData.Concat(cce.GetImportCompletionData(startPos));
if (!completionContext.OnlyTypeMembersFitAtPosition(startPos)) {
completionData = completionData.Concat(cce.GetImportCompletionData(startPos));
}
} else {
startPos = caretOffset;
if (char.IsLetterOrDigit (completionChar) || completionChar == '_') {

25
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionContext.cs

@ -80,6 +80,31 @@ namespace CSharpBinding.Completion @@ -80,6 +80,31 @@ namespace CSharpBinding.Completion
return new CSharpCompletionContext(editor, EmptyList<string>.Instance, compilation, projectContent, document, unresolvedFile, currentLocation);
}
/// <summary>
/// Look back for the nearest char that is not a part of an identifier or a whitespace.
/// (We don't stop on whitespaces because it is legal to have a piece of code like "Foo. Bar(). Baz()")
/// If the char we found is a dot, then the code completion suggestions should only include type members,
/// but not types from the outer scope.
/// If the char we found is not a dot (e. g., a semicolon), then the code completion suggestions can include type names.
/// </summary>
public bool OnlyTypeMembersFitAtPosition(int offset)
{
var c = '\0';
var pos = offset - 1;
while (pos >= 0)
{
c = Document.GetCharAt(pos);
if (!char.IsLetterOrDigit(c) && c != '_' && !char.IsWhiteSpace(c))
break;
pos--;
}
if (pos == -1 || c != '.')
return false;
return true;
}
private CSharpCompletionContext(ITextEditor editor, IList<string> conditionalSymbols, ICompilation compilation, IProjectContent projectContent, IDocument document, CSharpUnresolvedFile unresolvedFile, TextLocation caretLocation)
{

Loading…
Cancel
Save