Commit 720ada54 authored by Romain Bioteau's avatar Romain Bioteau

Fix groovy completion

parent d3de57b6
...@@ -55,13 +55,13 @@ public class VariablesCompletionProposalProvider implements IJavaCompletionPropo ...@@ -55,13 +55,13 @@ public class VariablesCompletionProposalProvider implements IJavaCompletionPropo
public List<ICompletionProposal> computeCompletionProposals(final ContentAssistInvocationContext context, final IProgressMonitor monitor) { public List<ICompletionProposal> computeCompletionProposals(final ContentAssistInvocationContext context, final IProgressMonitor monitor) {
final List<ICompletionProposal> list = new ArrayList<ICompletionProposal>(); final List<ICompletionProposal> list = new ArrayList<ICompletionProposal>();
if (context instanceof JavaContentAssistInvocationContext) { if (context instanceof JavaContentAssistInvocationContext) {
final ITextViewer viewer = context.getViewer();
final List<ScriptVariable> variables = getScriptVariables(viewer);
if (variables.isEmpty()) {
return list;
}
final ICompilationUnit unit = ((JavaContentAssistInvocationContext) context).getCompilationUnit(); final ICompilationUnit unit = ((JavaContentAssistInvocationContext) context).getCompilationUnit();
if (unit instanceof GroovyCompilationUnit) { if (unit instanceof GroovyCompilationUnit) {
final ITextViewer viewer = context.getViewer();
final List<ScriptVariable> variables = getScriptVariables(viewer);
if (variables.isEmpty()) {
return list;
}
if (((GroovyCompilationUnit) unit).getModuleNode() == null) { if (((GroovyCompilationUnit) unit).getModuleNode() == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
......
...@@ -35,7 +35,6 @@ import org.codehaus.groovy.eclipse.codeassist.requestor.ContentAssistContext; ...@@ -35,7 +35,6 @@ import org.codehaus.groovy.eclipse.codeassist.requestor.ContentAssistContext;
import org.codehaus.groovy.eclipse.codeassist.requestor.GroovyCompletionProposalComputer; import org.codehaus.groovy.eclipse.codeassist.requestor.GroovyCompletionProposalComputer;
import org.codehaus.jdt.groovy.model.GroovyCompilationUnit; import org.codehaus.jdt.groovy.model.GroovyCompilationUnit;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.CompletionContext;
import org.eclipse.jdt.core.CompletionProposal; import org.eclipse.jdt.core.CompletionProposal;
import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IJavaProject;
...@@ -43,8 +42,6 @@ import org.eclipse.jdt.core.IMethod; ...@@ -43,8 +42,6 @@ import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.groovy.core.util.ReflectionUtils;
import org.eclipse.jdt.internal.codeassist.InternalCompletionContext;
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer;
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
...@@ -70,18 +67,20 @@ public class VariablesTypeCompletionProposal implements IJavaCompletionProposalC ...@@ -70,18 +67,20 @@ public class VariablesTypeCompletionProposal implements IJavaCompletionProposalC
public List<ICompletionProposal> computeCompletionProposals(final ContentAssistInvocationContext context, final IProgressMonitor monitor) { public List<ICompletionProposal> computeCompletionProposals(final ContentAssistInvocationContext context, final IProgressMonitor monitor) {
final List<ICompletionProposal> list = new ArrayList<ICompletionProposal>(); final List<ICompletionProposal> list = new ArrayList<ICompletionProposal>();
if (context instanceof JavaContentAssistInvocationContext) { if (context instanceof JavaContentAssistInvocationContext) {
final CompletionContext coreContext = ((JavaContentAssistInvocationContext) context).getCoreContext(); final ITextViewer viewer = context.getViewer();
if (coreContext != null && !coreContext.isExtended()) { final List<ScriptVariable> scriptVariables = getScriptVariables(viewer);
// must use reflection to set the fields if (scriptVariables.isEmpty()) {
ReflectionUtils.setPrivateField(InternalCompletionContext.class, "isExtended", coreContext, true); return list;
} }
// final CompletionContext coreContext = ((JavaContentAssistInvocationContext) context).getCoreContext();
// if (coreContext != null && !coreContext.isExtended()) {
// // must use reflection to set the fields
// ReflectionUtils.setPrivateField(InternalCompletionContext.class, "isExtended", coreContext, true);
// ReflectionUtils.setPrivateField(InternalCompletionContext.class, "extendedContext", coreContext,
// new GroovyExtendedCompletionContext(getContext(), requestor.currentScope));
// }
final ICompilationUnit unit = ((JavaContentAssistInvocationContext) context).getCompilationUnit(); final ICompilationUnit unit = ((JavaContentAssistInvocationContext) context).getCompilationUnit();
if (unit instanceof GroovyCompilationUnit) { if (unit instanceof GroovyCompilationUnit) {
final ITextViewer viewer = context.getViewer();
final List<ScriptVariable> scriptVariables = getScriptVariables(viewer);
if (scriptVariables.isEmpty()) {
return list;
}
if (((GroovyCompilationUnit) unit).getModuleNode() == null) { if (((GroovyCompilationUnit) unit).getModuleNode() == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment