* @param addToNotDefined determines if it should be added to the 'not defined tokens' stack or not
* @return true if it was found
*/
protected boolean markRead(IToken token, String rep, boolean addToNotDefined, boolean checkIfIsValidImportToken) {
boolean found = false;
Found foundAs = null;
String foundAsStr = null;
int acceptedScopes = 0;
ScopeItems currScopeItems = scope.getCurrScopeItems();
if ((currScopeItems.getScopeType() & Scope.ACCEPTED_METHOD_AND_LAMBDA) != 0) {
acceptedScopes = Scope.ACCEPTED_METHOD_SCOPES;
} else {
acceptedScopes = Scope.ACCEPTED_ALL_SCOPES;
}
if ("locals".equals(rep)) {
//if locals() is accessed, all the tokens currently found are marked as 'used'
//use case:
//
//def f2():
// a = 1
// b = 2
// c = 3
// f1(**locals())
currScopeItems.setAllUsed();
return true;
}
Iterator<String> it = new FullRepIterable(rep, true).iterator();
//search for it
while (found == false && it.hasNext()) {
String nextTokToSearch = it.next();
foundAs = scope.findFirst(nextTokToSearch, true, acceptedScopes);
found = foundAs != null;
if (found) {
foundAsStr = nextTokToSearch;
foundAs.getSingle().references.add(token);
onFoundTokenAs(token, foundAs);
}
}
if (!found) {
//this token might not be defined... (still, might be in names to ignore)
int i;
if ((i = rep.indexOf('.')) != -1) {
//if it is an attribute, we have to check the names to ignore just with its first part
rep = rep.substring(0, i);
}
if (addToNotDefined) {
com.aptana.shared_core.structure.Tuple<IToken, Found> foundInNamesToIgnore = findInNamesToIgnore(rep, token);
if (foundInNamesToIgnore == null) {
Found foundForProbablyNotDefined = makeFound(token);
if (scope.size() > 1) { //if we're not in the global scope, it might be defined later
probablyNotDefined.add(foundForProbablyNotDefined); //we are not in the global scope, so it might be defined later...
onAddToProbablyNotDefined(token, foundForProbablyNotDefined);
} else {
onAddUndefinedMessage(token, foundForProbablyNotDefined); //it is in the global scope, so, it is undefined.