Lines 10-15
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.internal.eval; |
11 |
package org.eclipse.jdt.internal.eval; |
12 |
|
12 |
|
|
|
13 |
import java.util.Locale; |
13 |
import java.util.Map; |
14 |
import java.util.Map; |
14 |
|
15 |
|
15 |
import org.eclipse.jdt.core.CompletionRequestor; |
16 |
import org.eclipse.jdt.core.CompletionRequestor; |
Lines 20-28
Link Here
|
20 |
import org.eclipse.jdt.internal.codeassist.SelectionEngine; |
21 |
import org.eclipse.jdt.internal.codeassist.SelectionEngine; |
21 |
import org.eclipse.jdt.internal.compiler.ClassFile; |
22 |
import org.eclipse.jdt.internal.compiler.ClassFile; |
22 |
import org.eclipse.jdt.internal.compiler.IProblemFactory; |
23 |
import org.eclipse.jdt.internal.compiler.IProblemFactory; |
|
|
24 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; |
25 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; |
23 |
import org.eclipse.jdt.internal.compiler.env.IBinaryType; |
26 |
import org.eclipse.jdt.internal.compiler.env.IBinaryType; |
24 |
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; |
27 |
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; |
25 |
import org.eclipse.jdt.internal.compiler.env.INameEnvironment; |
28 |
import org.eclipse.jdt.internal.compiler.env.INameEnvironment; |
|
|
29 |
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; |
26 |
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; |
30 |
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; |
27 |
import org.eclipse.jdt.internal.compiler.util.SuffixConstants; |
31 |
import org.eclipse.jdt.internal.compiler.util.SuffixConstants; |
28 |
import org.eclipse.jdt.internal.core.SearchableEnvironment; |
32 |
import org.eclipse.jdt.internal.core.SearchableEnvironment; |
Lines 98-103
Link Here
|
98 |
* set of options used to configure the code assist engine. |
102 |
* set of options used to configure the code assist engine. |
99 |
*/ |
103 |
*/ |
100 |
public void complete(char[] codeSnippet, int completionPosition, SearchableEnvironment environment, CompletionRequestor requestor, Map options, IJavaProject project) { |
104 |
public void complete(char[] codeSnippet, int completionPosition, SearchableEnvironment environment, CompletionRequestor requestor, Map options, IJavaProject project) { |
|
|
105 |
try { |
106 |
IRequestor variableRequestor = new IRequestor() { |
107 |
public boolean acceptClassFiles(ClassFile[] classFiles, char[] codeSnippetClassName) { |
108 |
// Do nothing |
109 |
return true; |
110 |
} |
111 |
public void acceptProblem(CategorizedProblem problem, char[] fragmentSource, int fragmentKind) { |
112 |
// Do nothing |
113 |
} |
114 |
}; |
115 |
this.evaluateVariables(environment, options, variableRequestor, new DefaultProblemFactory(Locale.getDefault())); |
116 |
} catch (InstallException e) { |
117 |
// Do nothing |
118 |
} |
101 |
final char[] className = "CodeSnippetCompletion".toCharArray(); //$NON-NLS-1$ |
119 |
final char[] className = "CodeSnippetCompletion".toCharArray(); //$NON-NLS-1$ |
102 |
final CodeSnippetToCuMapper mapper = new CodeSnippetToCuMapper( |
120 |
final CodeSnippetToCuMapper mapper = new CodeSnippetToCuMapper( |
103 |
codeSnippet, |
121 |
codeSnippet, |
Lines 125-131
Link Here
|
125 |
return null; |
143 |
return null; |
126 |
} |
144 |
} |
127 |
}; |
145 |
}; |
|
|
146 |
|
128 |
CompletionEngine engine = new CompletionEngine(environment, mapper.getCompletionRequestor(requestor), options, project); |
147 |
CompletionEngine engine = new CompletionEngine(environment, mapper.getCompletionRequestor(requestor), options, project); |
|
|
148 |
|
149 |
if (this.installedVars != null) { |
150 |
IBinaryType binaryType = this.getRootCodeSnippetBinary(); |
151 |
if (binaryType != null) { |
152 |
engine.lookupEnvironment.cacheBinaryType(binaryType, null /*no access restriction*/); |
153 |
} |
154 |
|
155 |
ClassFile[] classFiles = installedVars.classFiles; |
156 |
for (int i = 0; i < classFiles.length; i++) { |
157 |
ClassFile classFile = classFiles[i]; |
158 |
IBinaryType binary = null; |
159 |
try { |
160 |
binary = new ClassFileReader(classFile.getBytes(), null); |
161 |
} catch (ClassFormatException e) { |
162 |
e.printStackTrace(); // Should never happen since we compiled this type |
163 |
} |
164 |
engine.lookupEnvironment.cacheBinaryType(binary, null /*no access restriction*/); |
165 |
} |
166 |
} |
167 |
|
129 |
engine.complete(sourceUnit, mapper.startPosOffset + completionPosition, mapper.startPosOffset); |
168 |
engine.complete(sourceUnit, mapper.startPosOffset + completionPosition, mapper.startPosOffset); |
130 |
} |
169 |
} |
131 |
/** |
170 |
/** |