public class ImportConflictDetector extends AbstractProcessor<CtElement>
class A {
int xxx;
void m(String xxx) {
this.xxx //the target `this.` must be explicit, otherwise parameter `String xxx` hides it
}
}
2) Example: conflict of package name with an variable name and fixes it by making field target implicit.
class A {
int com;
void m() {
com.package.Type.doSomething(); //the package `com` is in conflict with field `com`. Must be imported
}
}
and fixes them by call of CtElement.setImplicit(boolean)
and CtTypeReference.setSimplyQualified(boolean)
Modifier and Type | Field and Description |
---|---|
protected static java.util.Set<CtRole> |
IGNORED_ROLES_WHEN_IMPLICIT |
protected EarlyTerminatingScanner |
scanner |
Constructor and Description |
---|
ImportConflictDetector() |
Modifier and Type | Method and Description |
---|---|
protected LexicalScopeScanner |
createScanner()
creates the scanner that will be used to visit the model
|
protected CtScannerListener |
createScannerListener() |
protected static <T extends CtElement> |
getParentIfType(CtElement element,
java.lang.Class<T> type) |
protected LexicalScope |
getScannerContextInformation()
extract the required information from the scanner to take a decision
|
protected void |
handleTargetedExpression(CtTargetedExpression<?,?> targetedExpression,
LexicalScope nameScope)
what do we do a target expression (print target or not) ?
|
protected void |
handleTypeReference(CtTypeReference<?> ref,
LexicalScope nameScope,
CtRole role)
what do we do a type reference?
|
protected void |
onEnter(U context,
CtRole role,
CtElement element) |
void |
process(CtElement el)
A callback method upcalled by the meta-model scanner to perform a
dedicated job on the currently scanned element.
|
protected static void |
process(CtScanner scanner,
CtCompilationUnit cu) |
addProcessedElementType, clearProcessedElementType, getEnvironment, getFactory, getProcessedElementTypes, getTraversalStrategy, init, initProperties, interrupt, isToBeProcessed, loadProperties, process, processingDone, removeProcessedElementType, setFactory
protected EarlyTerminatingScanner scanner
protected static java.util.Set<CtRole> IGNORED_ROLES_WHEN_IMPLICIT
protected LexicalScopeScanner createScanner()
protected LexicalScope getScannerContextInformation()
protected void handleTargetedExpression(CtTargetedExpression<?,?> targetedExpression, LexicalScope nameScope)
protected void handleTypeReference(CtTypeReference<?> ref, LexicalScope nameScope, CtRole role)
public void process(CtElement el)
Processor
Processor.getProcessedElementTypes()
), the traversal strategy (
Processor.getTraversalStrategy()
), and the used processing manager (
Environment.getManager()
. Also, this method is upcalled only if
the method Processor.isToBeProcessed(CtElement)
returns true for a given
scanned element. In order to manually scan the meta-model, one can define
the Processor.process()
method instead.el
- the element that is currently being scannedprotected static void process(CtScanner scanner, CtCompilationUnit cu)
protected CtScannerListener createScannerListener()
Copyright © 2007–2021 Inria. All rights reserved.