Skip to content

Commit

Permalink
[bugfix] fix completion/resolution for types when using the qualified…
Browse files Browse the repository at this point in the history
… form.

Signed-off-by: Mihai Claudiu Toader <mtoader@gmail.com>
  • Loading branch information
mtoader committed Jul 31, 2012
1 parent 8bd1a43 commit b43fb5f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin version="2" url="http://github.com/mtoader/google-go-lang-idea-plugin">
<id>ro.redeul.google.go</id>
<name>Google Go language</name>
<version>0.9.3</version>
<version>0.9.4</version>
<vendor email="mtoader@gmail.com" url="http://redeul.ro">mtoader@gmail.com</vendor>
<description>
<![CDATA[
Expand Down Expand Up @@ -51,6 +51,11 @@
</description>
<change-notes>
<![CDATA[
<h3>0.9.4 changes:</h3>
<ul>
<li>[bugfix] Fix typename resolution for qualified types.</li>
</ul>
<h3>0.9.3 changes:</h3>
<ul>
<li>[feature] Added a warning about corrupt SDK inside a project.</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiErrorElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.impl.DebugUtil;
import com.intellij.util.PlatformIcons;
import com.intellij.util.ProcessingContext;
Expand All @@ -31,6 +32,7 @@
import ro.redeul.google.go.lang.psi.statements.GoExpressionStatement;
import ro.redeul.google.go.lang.psi.statements.GoGoStatement;
import ro.redeul.google.go.lang.psi.toplevel.GoImportDeclaration;
import ro.redeul.google.go.lang.psi.toplevel.GoImportDeclarations;
import ro.redeul.google.go.lang.psi.toplevel.GoPackageDeclaration;
import ro.redeul.google.go.lang.psi.types.GoPsiTypeName;
import ro.redeul.google.go.lang.psi.typing.GoTypes;
Expand Down Expand Up @@ -162,6 +164,25 @@ protected void addCompletions(@NotNull CompletionParameters params,
}
};

CompletionProvider<CompletionParameters> localImportsCompletion = new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiFile originalFile = parameters.getOriginalFile();
if (!(originalFile instanceof GoFile))
return;

GoFile file = (GoFile) originalFile;

for (GoImportDeclarations importDecls : file.getImportDeclarations()) {
for (GoImportDeclaration importDecl : importDecls.getDeclarations()) {
result.addElement(LookupElementBuilder.create(importDecl.getVisiblePackageName() + "."));
}
}
}
};

CompletionProvider<CompletionParameters> debuggingCompletionProvider = new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public boolean isReferenceTo(PsiElement element) {
= (GoTypeNameDeclaration) element;

return matchesVisiblePackageName(typeNameDecl,
getElement().getName());
getElement().getIdentifier().getName());
}

return false;
Expand Down Expand Up @@ -101,6 +101,7 @@ protected boolean addDeclaration(PsiElement declaration, PsiElement childDeclara
variants.add(
createLookupElement(
goDeclaration,
name,
goChildDeclaration));
return true;

Expand Down

0 comments on commit b43fb5f

Please sign in to comment.