Skip to content

Commit 142aed2

Browse files
Rob Strykerdatho7561
authored andcommitted
Isolate access within InternalCompletionProposal to the engine via dedicated protected methods
Signed-off-by: Rob Stryker <[email protected]>
1 parent f25458e commit 142aed2

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected char[][] findConstructorParameterNames(char[] declaringTypePackageName
207207
int length = paramTypeNames.length;
208208

209209
char[] tName = CharOperation.concat(declaringTypePackageName,declaringTypeName,'.');
210-
Object cachedType = this.completionEngine.typeCache.get(tName);
210+
Object cachedType = getFromEngineTypeCache(tName);
211211

212212
IType type = null;
213213
if(cachedType != null) {
@@ -226,7 +226,7 @@ protected char[][] findConstructorParameterNames(char[] declaringTypePackageName
226226
null);
227227
type = answer == null ? null : answer.type;
228228
if(type instanceof BinaryType){
229-
this.completionEngine.typeCache.put(tName, type);
229+
addToCompletionEngineTypeCache(tName, type);
230230
} else {
231231
type = null;
232232
}
@@ -242,14 +242,15 @@ protected char[][] findConstructorParameterNames(char[] declaringTypePackageName
242242

243243
IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot)type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
244244
if (packageFragmentRoot.isArchive() ||
245-
this.completionEngine.openedBinaryTypes < getOpenedBinaryTypesThreshold()) {
245+
getOpenedBinaryTypesCount() < getOpenedBinaryTypesThreshold()) {
246246
SourceMapper mapper = ((JavaElement)method).getSourceMapper();
247247
if (mapper != null) {
248248
char[][] paramNames = mapper.getMethodParameterNames(method);
249249

250250
// map source and try to find parameter names
251251
if(paramNames == null) {
252-
if (!packageFragmentRoot.isArchive()) this.completionEngine.openedBinaryTypes++;
252+
if (!packageFragmentRoot.isArchive())
253+
incrementOpenedBinaryTypesCount();
253254
IBinaryType info = ((BinaryType) type).getElementInfo();
254255
char[] source = mapper.findSource(type, info);
255256
if (source != null){
@@ -290,14 +291,30 @@ this.completionEngine.openedBinaryTypes < getOpenedBinaryTypesThreshold()) {
290291
return parameters;
291292
}
292293

294+
protected void incrementOpenedBinaryTypesCount() {
295+
this.completionEngine.openedBinaryTypes++;
296+
}
297+
298+
protected int getOpenedBinaryTypesCount() {
299+
return this.completionEngine.openedBinaryTypes;
300+
}
301+
302+
protected void addToCompletionEngineTypeCache(char[] tName, IType type) {
303+
this.completionEngine.typeCache.put(tName, type);
304+
}
305+
306+
protected Object getFromEngineTypeCache(char[] tName) {
307+
return this.completionEngine.typeCache.get(tName);
308+
}
309+
293310
protected char[][] findMethodParameterNames(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] paramTypeNames){
294311
if(paramTypeNames == null || declaringTypeName == null) return null;
295312

296313
char[][] parameters = null;
297314
int length = paramTypeNames.length;
298315

299316
char[] tName = CharOperation.concat(declaringTypePackageName,declaringTypeName,'.');
300-
Object cachedType = this.completionEngine.typeCache.get(tName);
317+
Object cachedType = getFromEngineTypeCache(tName);
301318

302319
IType type = null;
303320
if(cachedType != null) {
@@ -316,7 +333,7 @@ protected char[][] findMethodParameterNames(char[] declaringTypePackageName, cha
316333
null);
317334
type = answer == null ? null : answer.type;
318335
if(type instanceof BinaryType){
319-
this.completionEngine.typeCache.put(tName, type);
336+
addToCompletionEngineTypeCache(tName, type);
320337
} else {
321338
type = null;
322339
}

0 commit comments

Comments
 (0)