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