-
-
Notifications
You must be signed in to change notification settings - Fork 242
/
CtxParticipant.java
574 lines (515 loc) · 26.9 KB
/
CtxParticipant.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
/**
* Copyright (c) 2005-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Eclipse Public License (EPL).
* Please see the license.txt included with this distribution for details.
* Any modifications to this file must keep this entire header intact.
*/
/*
* Created on 07/09/2005
*/
package com.python.pydev.codecompletion.ctxinsensitive;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.IAdaptable;
import org.python.pydev.ast.codecompletion.CompletionRequest;
import org.python.pydev.ast.codecompletion.IPyDevCompletionParticipant;
import org.python.pydev.ast.codecompletion.IPyDevCompletionParticipant2;
import org.python.pydev.ast.codecompletion.IPyDevCompletionParticipant3;
import org.python.pydev.ast.codecompletion.ProposalsComparator.CompareContext;
import org.python.pydev.ast.codecompletion.PyCodeCompletionPreferences;
import org.python.pydev.ast.codecompletion.PyCodeCompletionUtils;
import org.python.pydev.ast.codecompletion.PyCodeCompletionUtils.IFilter;
import org.python.pydev.ast.codecompletion.revisited.modules.SourceToken;
import org.python.pydev.ast.codecompletion.revisited.visitors.Definition;
import org.python.pydev.ast.item_pointer.ItemPointer;
import org.python.pydev.core.ICodeCompletionASTManager;
import org.python.pydev.core.ICompletionState;
import org.python.pydev.core.ICompletionState.LookingFor;
import org.python.pydev.core.IDefinition;
import org.python.pydev.core.IInfo;
import org.python.pydev.core.ILocalScope;
import org.python.pydev.core.IModule;
import org.python.pydev.core.IPythonNature;
import org.python.pydev.core.IToken;
import org.python.pydev.core.IterTokenEntry;
import org.python.pydev.core.MisconfigurationException;
import org.python.pydev.core.NoExceptionCloseable;
import org.python.pydev.core.TokensList;
import org.python.pydev.core.TokensOrProposalsList;
import org.python.pydev.core.docutils.PySelection.ActivationTokenAndQualifier;
import org.python.pydev.core.interactive_console.IScriptConsoleViewer;
import org.python.pydev.core.log.Log;
import org.python.pydev.core.proposals.CompletionProposalFactory;
import org.python.pydev.core.structure.CompletionRecursionException;
import org.python.pydev.parser.jython.SimpleNode;
import org.python.pydev.parser.jython.ast.FunctionDef;
import org.python.pydev.parser.jython.ast.Name;
import org.python.pydev.parser.jython.ast.decoratorsType;
import org.python.pydev.parser.visitors.NodeUtils;
import org.python.pydev.plugin.nature.SystemPythonNature;
import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle;
import org.python.pydev.shared_core.code_completion.IPyCompletionProposal;
import org.python.pydev.shared_core.model.ISimpleNode;
import org.python.pydev.shared_core.string.FastStringBuffer;
import org.python.pydev.shared_core.string.FullRepIterable;
import org.python.pydev.shared_core.structure.FastStack;
import org.python.pydev.shared_core.structure.LinkedListWarningOnSlowOperations;
import com.python.pydev.analysis.AnalysisPlugin;
import com.python.pydev.analysis.AnalysisPreferences;
import com.python.pydev.analysis.additionalinfo.AbstractAdditionalTokensInfo;
import com.python.pydev.analysis.additionalinfo.AdditionalProjectInterpreterInfo;
import com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo;
/**
* Provides the completions in a context-insensitive way for classes and methods (both for the editor or the console).
*
* @author Fabio
*/
public class CtxParticipant
implements IPyDevCompletionParticipant, IPyDevCompletionParticipant2, IPyDevCompletionParticipant3 {
// Console completions ---------------------------------------------------------------------------------------------
/**
* IPyDevCompletionParticipant2
*/
@Override
public Collection<ICompletionProposalHandle> computeConsoleCompletions(ActivationTokenAndQualifier tokenAndQual,
Set<IPythonNature> naturesUsed, IScriptConsoleViewer viewer, int requestOffset) {
List<ICompletionProposalHandle> completions = new ArrayList<ICompletionProposalHandle>();
if (tokenAndQual.activationToken != null && tokenAndQual.activationToken.length() > 0) {
//we only want
return completions;
}
String qual = tokenAndQual.qualifier;
if (qual.length() >= PyCodeCompletionPreferences.getCharsForContextInsensitiveGlobalTokensCompletion()
&& naturesUsed != null && naturesUsed.size() > 0) { //at least n characters required...
boolean addAutoImport = AnalysisPreferences.doAutoImport(null);
int qlen = qual.length();
boolean useSubstringMatchInCodeCompletion = PyCodeCompletionPreferences
.getUseSubstringMatchInCodeCompletion();
IFilter nameFilter = PyCodeCompletionUtils.getNameFilter(useSubstringMatchInCodeCompletion, qual);
for (IPythonNature nature : naturesUsed) {
AbstractAdditionalTokensInfo additionalInfo;
try {
if (nature instanceof SystemPythonNature) {
SystemPythonNature systemPythonNature = (SystemPythonNature) nature;
additionalInfo = AdditionalSystemInterpreterInfo.getAdditionalSystemInfo(
systemPythonNature.getRelatedInterpreterManager(),
systemPythonNature.getProjectInterpreter().getExecutableOrJar());
fillNatureCompletionsForConsole(viewer, requestOffset, completions, qual, addAutoImport, qlen,
nameFilter, nature, additionalInfo, useSubstringMatchInCodeCompletion);
} else {
additionalInfo = AdditionalProjectInterpreterInfo.getAdditionalInfoForProject(nature);
fillNatureCompletionsForConsole(viewer, requestOffset, completions, qual, addAutoImport, qlen,
nameFilter, nature, additionalInfo, useSubstringMatchInCodeCompletion);
}
} catch (MisconfigurationException e) {
Log.log(e);
}
}
}
return completions;
}
private void fillNatureCompletionsForConsole(IScriptConsoleViewer viewer, int requestOffset,
List<ICompletionProposalHandle> completions, String qual, boolean addAutoImport, int qlen,
IFilter nameFilter,
IPythonNature nature, AbstractAdditionalTokensInfo additionalInfo,
boolean useSubstringMatchInCodeCompletion) {
Collection<IInfo> tokensStartingWith;
if (useSubstringMatchInCodeCompletion) {
tokensStartingWith = additionalInfo.getTokensStartingWith("",
AbstractAdditionalTokensInfo.TOP_LEVEL);
} else {
tokensStartingWith = additionalInfo.getTokensStartingWith(qual,
AbstractAdditionalTokensInfo.TOP_LEVEL);
}
FastStringBuffer realImportRep = new FastStringBuffer();
FastStringBuffer displayString = new FastStringBuffer();
FastStringBuffer tempBuf = new FastStringBuffer();
boolean doIgnoreImportsStartingWithUnder = AnalysisPreferences.doIgnoreImportsStartingWithUnder(null);
CompareContext compareContext = new CompareContext(nature);
for (IInfo info : tokensStartingWith) {
//there always must be a declaringModuleName
String declaringModuleName = info.getDeclaringModuleName();
boolean hasInit = false;
if (declaringModuleName.endsWith(".__init__")) {
declaringModuleName = declaringModuleName.substring(0, declaringModuleName.length() - 9);//remove the .__init__
hasInit = true;
}
String rep = info.getName();
if (!nameFilter.acceptName(rep)) {
continue;
}
if (addAutoImport) {
realImportRep.clear();
realImportRep.append("from ");
realImportRep.append(AnalysisPreferences.removeImportsStartingWithUnderIfNeeded(
declaringModuleName, tempBuf, doIgnoreImportsStartingWithUnder));
realImportRep.append(" import ");
realImportRep.append(rep);
}
displayString.clear();
displayString.append(rep);
displayString.append(" - ");
displayString.append(declaringModuleName);
if (hasInit) {
displayString.append(".__init__");
}
String displayAsStr = displayString.toString();
ICompletionProposalHandle proposal = CompletionProposalFactory.get()
.createPyConsoleCompletion(rep, requestOffset - qlen, qlen, realImportRep.length(),
info.getType(), displayAsStr, null, "",
displayAsStr.equals(qual) ? IPyCompletionProposal.PRIORITY_GLOBALS_EXACT
: IPyCompletionProposal.PRIORITY_GLOBALS,
realImportRep.toString(), viewer, compareContext);
completions.add(proposal);
}
}
// Editor completions ----------------------------------------------------------------------------------------------
private Collection<ICompletionProposalHandle> getThem(CompletionRequest request, ICompletionState state,
boolean addAutoImport) throws MisconfigurationException {
List<ICompletionProposalHandle> completions = new ArrayList<>();
if (request.isInCalltip) {
return completions;
}
HashSet<String> importedNames = getImportedNames(state);
String qual = request.qualifier;
if (qual.length() >= PyCodeCompletionPreferences.getCharsForContextInsensitiveGlobalTokensCompletion()) { //at least n characters required...
IFilter nameFilter = PyCodeCompletionUtils.getNameFilter(request.useSubstringMatchInCodeCompletion, qual);
String initialModule = request.resolveModule();
List<IInfo> tokensStartingWith;
if (request.useSubstringMatchInCodeCompletion) {
tokensStartingWith = AdditionalProjectInterpreterInfo.getTokensStartingWith("",
request.nature, AbstractAdditionalTokensInfo.TOP_LEVEL);
} else {
tokensStartingWith = AdditionalProjectInterpreterInfo.getTokensStartingWith(qual,
request.nature, AbstractAdditionalTokensInfo.TOP_LEVEL);
}
FastStringBuffer realImportRep = new FastStringBuffer();
FastStringBuffer displayString = new FastStringBuffer();
FastStringBuffer tempBuf = new FastStringBuffer();
IAdaptable projectAdaptable = request.getNature() != null ? request.getNature().getProject() : null;
boolean doIgnoreImportsStartingWithUnder = AnalysisPreferences
.doIgnoreImportsStartingWithUnder(projectAdaptable);
for (IInfo info : tokensStartingWith) {
//there always must be a declaringModuleName
String declaringModuleName = info.getDeclaringModuleName();
if (initialModule != null && declaringModuleName != null) {
if (initialModule.equals(declaringModuleName) || "builtins".equals(declaringModuleName)
|| "__builtin__".equals(declaringModuleName)) {
continue;
}
}
boolean hasInit = false;
if (declaringModuleName.endsWith(".__init__")) {
declaringModuleName = declaringModuleName.substring(0, declaringModuleName.length() - 9);//remove the .__init__
hasInit = true;
}
String rep = info.getName();
if (!nameFilter.acceptName(rep) || importedNames.contains(rep)) {
continue;
}
if (addAutoImport) {
realImportRep.clear();
realImportRep.append("from ");
realImportRep.append(AnalysisPreferences.removeImportsStartingWithUnderIfNeeded(
declaringModuleName, tempBuf, doIgnoreImportsStartingWithUnder));
realImportRep.append(" import ");
realImportRep.append(rep);
}
displayString.clear();
displayString.append(rep);
displayString.append(" - ");
displayString.append(declaringModuleName);
if (hasInit) {
displayString.append(".__init__");
}
String displayAsStr = displayString.toString();
ICompletionProposalHandle proposal = CompletionProposalFactory.get()
.createCtxInsensitiveImportComplProposal(rep, request.documentOffset - request.qlen,
request.qlen, realImportRep.length(), info.getType(), displayAsStr,
null, "",
displayAsStr.equals(qual) ? IPyCompletionProposal.PRIORITY_GLOBALS_EXACT
: IPyCompletionProposal.PRIORITY_GLOBALS,
realImportRep.toString(), new CompareContext(info.getNature()));
completions.add(proposal);
}
}
return completions;
}
/**
* @return the names that are already imported in the current document
*/
private HashSet<String> getImportedNames(ICompletionState state) {
TokensList tokenImportedModules = state.getTokenImportedModules();
HashSet<String> importedNames = new HashSet<String>();
if (tokenImportedModules != null) {
for (IterTokenEntry entry : tokenImportedModules) {
IToken token = entry.getToken();
importedNames.add(token.getRepresentation());
}
}
return importedNames;
}
@Override
public TokensOrProposalsList getGlobalCompletions(CompletionRequest request, ICompletionState state)
throws MisconfigurationException {
IAdaptable projectAdaptable = request.getNature() != null ? request.getNature().getProject() : null;
return new TokensOrProposalsList(getThem(request, state, AnalysisPreferences.doAutoImport(projectAdaptable)));
}
@Override
public IDefinition findDefinitionForMethodParameter(Definition d, IPythonNature nature,
ICompletionState completionCache) {
if (d.ast instanceof Name) {
Name name = (Name) d.ast;
if (name.ctx == Name.Param) {
if (d.scope != null && !d.scope.getScopeStack().empty()) {
Object peek = d.scope.getScopeStack().peek();
if (peek instanceof FunctionDef) {
FunctionDef functionDef = (FunctionDef) peek;
String representationString = NodeUtils.getRepresentationString(functionDef);
if (representationString != null && representationString.startsWith("test")) {
ItemPointer itemPointer = findItemPointerFromPyTestFixture(nature, completionCache,
name.id);
if (itemPointer != null) {
return itemPointer.definition;
}
}
}
}
}
}
return null;
}
private ItemPointer findItemPointerFromPyTestFixture(IPythonNature nature, ICompletionState completionCache,
String fixtureName) {
try {
ICodeCompletionASTManager astManager = nature.getAstManager();
if (astManager != null) {
List<IInfo> tokensEqualTo = AdditionalProjectInterpreterInfo.getTokensEqualTo(
fixtureName, nature, AdditionalProjectInterpreterInfo.TOP_LEVEL);
for (IInfo iInfo : tokensEqualTo) {
List<ItemPointer> pointers = new LinkedListWarningOnSlowOperations<>();
AnalysisPlugin.getDefinitionFromIInfo(pointers, astManager, nature, iInfo,
completionCache, true, true);
for (ItemPointer itemPointer : pointers) {
if (itemPointer.definition.ast instanceof FunctionDef) {
FunctionDef functionDef = (FunctionDef) itemPointer.definition.ast;
if (functionDef.decs != null) {
for (decoratorsType dec : functionDef.decs) {
String decoratorFuncName = NodeUtils.getRepresentationString(dec.func);
if (decoratorFuncName != null) {
if (FIXTURE_PATTERN.matcher(decoratorFuncName).find()
|| YIELD_FIXTURE_PATTERN.matcher(decoratorFuncName)
.find()) {
return itemPointer;
}
}
}
}
}
}
}
}
} catch (MisconfigurationException e1) {
Log.log(e1);
}
return null;
}
private final static Pattern FIXTURE_PATTERN = Pattern.compile("\\bfixture\\b");
private final static Pattern YIELD_FIXTURE_PATTERN = Pattern.compile("\\byield_fixture\\b");
/**
* IPyDevCompletionParticipant
* @throws CompletionRecursionException
*/
@Override
public TokensList getCompletionsForMethodParameter(ICompletionState state, ILocalScope localScope,
TokensList interfaceForLocal) throws CompletionRecursionException {
ArrayList<IToken> ret = new ArrayList<IToken>();
String qual = state.getQualifier();
String activationToken = state.getActivationToken();
FastStack<ISimpleNode> scopeStack = localScope.getScopeStack();
if (!scopeStack.empty()) {
Object peek = scopeStack.peek();
if (peek instanceof FunctionDef) {
FunctionDef testFuncDef = (FunctionDef) peek;
String representationString = NodeUtils.getRepresentationString(testFuncDef);
if (representationString != null && representationString.startsWith("test")) {
ICodeCompletionASTManager astManager = state.getNature().getAstManager();
if (astManager != null) {
ItemPointer itemPointer = findItemPointerFromPyTestFixture(state.getNature(), state,
activationToken);
if (itemPointer != null) {
TokensList completionsFromItemPointer = getCompletionsFromItemPointer(state, astManager,
itemPointer);
if (completionsFromItemPointer != null && completionsFromItemPointer.notEmpty()) {
return completionsFromItemPointer;
}
}
}
}
}
}
if (qual.length() >= PyCodeCompletionPreferences.getCharsForContextInsensitiveGlobalTokensCompletion()) { //at least n characters
// if we have a parameter, do code-completion with all available tokens, since we don't know what's the type which
// may actually be received
boolean useSubstringMatchInCodeCompletion = PyCodeCompletionPreferences
.getUseSubstringMatchInCodeCompletion();
List<IInfo> tokensStartingWith;
if (useSubstringMatchInCodeCompletion) {
IFilter nameFilter = PyCodeCompletionUtils.getNameFilter(useSubstringMatchInCodeCompletion, qual);
try {
tokensStartingWith = AdditionalProjectInterpreterInfo.getTokensStartingWith("", state.getNature(),
AbstractAdditionalTokensInfo.INNER);
} catch (MisconfigurationException e) {
Log.log(e);
return new TokensList(ret);
}
for (IInfo info : tokensStartingWith) {
if (nameFilter.acceptName(info.getName())) {
ret.add(new SourceToken(null, info.getName(), null, null, info.getDeclaringModuleName(),
info.getType(), info.getNature()));
}
}
} else {
try {
tokensStartingWith = AdditionalProjectInterpreterInfo.getTokensStartingWith(qual, state.getNature(),
AbstractAdditionalTokensInfo.INNER);
} catch (MisconfigurationException e) {
Log.log(e);
return new TokensList(ret);
}
for (IInfo info : tokensStartingWith) {
ret.add(new SourceToken(null, info.getName(), null, null, info.getDeclaringModuleName(),
info.getType(), info.getNature()));
}
}
}
return new TokensList(ret);
}
private TokensList getCompletionsFromItemPointer(ICompletionState state, ICodeCompletionASTManager astManager,
ItemPointer itemPointer) throws CompletionRecursionException {
try (NoExceptionCloseable x = state.pushLookingFor(
ICompletionState.LookingFor.LOOKING_FOR_INSTANCED_VARIABLE)) {
LookingFor currLookingFor = state.getLookingFor();
SimpleNode ast = itemPointer.definition.ast;
if (ast instanceof FunctionDef) {
FunctionDef functionDef = (FunctionDef) ast;
TokensList completionFromFuncDefReturn = astManager
.getCompletionFromFuncDefReturn(state,
itemPointer.definition.module,
functionDef, true);
if (completionFromFuncDefReturn != null
&& completionFromFuncDefReturn.notEmpty()) {
completionFromFuncDefReturn.setLookingFor(currLookingFor);
return completionFromFuncDefReturn;
}
}
}
return null;
}
/**
* IPyDevCompletionParticipant
* @throws MisconfigurationException
*/
@Override
public TokensOrProposalsList getStringGlobalCompletions(CompletionRequest request, ICompletionState state)
throws MisconfigurationException {
return new TokensOrProposalsList(getThem(request, state, false));
}
@Override
public TokensList getCompletionsForTokenWithUndefinedType(ICompletionState state, ILocalScope localScope,
TokensList interfaceForLocal) throws CompletionRecursionException {
return getCompletionsForMethodParameter(state, localScope, interfaceForLocal);
}
@Override
public TokensList getCompletionsForType(ICompletionState state) throws CompletionRecursionException {
String activationToken = state.getActivationToken();
String qual = activationToken;
String module = null;
if (activationToken.indexOf('.') != -1) {
String[] headAndTail = FullRepIterable.headAndTail(activationToken);
qual = headAndTail[1];
module = headAndTail[0];
}
try {
IPythonNature nature = state.getNature();
List<IInfo> tokensStartingWith = AdditionalProjectInterpreterInfo.getTokensEqualTo(qual,
nature, AbstractAdditionalTokensInfo.TOP_LEVEL | AbstractAdditionalTokensInfo.INNER);
int size = tokensStartingWith.size();
if (size == 0) {
return new TokensList();
}
if (size == 1) {
return getCompletionsForIInfo(state, nature, tokensStartingWith.get(0));
}
//If we got here, we have more than 1 choice: let's try to find it given the module.
if (module != null) {
for (int i = 0; i < size; i++) {
IInfo iInfo = tokensStartingWith.get(i);
if (module.equals(iInfo.getDeclaringModuleName())) {
TokensList ret = getCompletionsForIInfo(state, nature, iInfo);
if (ret != null && ret.notEmpty()) {
return ret; //seems like we found it.
}
}
}
}
//Couldn't find an exact match: go for the type (prefer classes).
ArrayList<IInfo> newList = new ArrayList<IInfo>();
for (int i = 0; i < size; i++) {
IInfo iInfo = tokensStartingWith.get(i);
if (iInfo.getType() == IInfo.CLASS_WITH_IMPORT_TYPE) {
newList.add(iInfo);
}
}
tokensStartingWith = newList;
size = tokensStartingWith.size();
if (size == 0) {
return null;
}
if (size == 1) {
return getCompletionsForIInfo(state, nature, tokensStartingWith.get(0));
}
if (size < 5) { // Don't go for it if we have too many things there!
TokensList ret = new TokensList();
for (int i = 0; i < size; i++) {
IInfo iInfo = tokensStartingWith.get(i);
TokensList found = getCompletionsForIInfo(state, nature, iInfo);
if (found != null) {
ret.addAll(found);
}
}
return ret;
}
return null; //Too many matches: skip this one (instead of returning something random).
} catch (MisconfigurationException e) {
return null;
}
}
/**
* Gets completions given a module and related info.
*/
private TokensList getCompletionsForIInfo(ICompletionState state, IPythonNature nature, IInfo iInfo)
throws CompletionRecursionException {
ICompletionState copy = state.getCopy();
String path = iInfo.getPath();
String act = iInfo.getName();
if (path != null) {
act = path + "." + act;
}
copy.setActivationToken(act);
ICodeCompletionASTManager manager = nature.getAstManager();
IModule mod = manager.getModule(iInfo.getDeclaringModuleName(), nature, true, state);
if (mod != null) {
state.checkFindDefinitionMemory(mod, iInfo.getDeclaringModuleName() + "." + act);
TokensList tks = manager.getCompletionsForModule(mod, copy);
if (tks != null) {
return tks;
}
}
return null;
}
}