Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java @ 18757:0ec5f5a2e720
Truffle-DSL: disable automatic static imports.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 29 Dec 2014 23:38:39 +0100 |
parents | c22714b214d0 |
children |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java Mon Dec 29 23:38:34 2014 +0100 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java Mon Dec 29 23:38:39 2014 +0100 @@ -36,7 +36,6 @@ public final class OrganizedImports { private final Map<String, String> classImportUsage = new HashMap<>(); - private final Map<String, String> staticImportUsage = new HashMap<>(); private final Map<String, Set<String>> autoImportCache = new HashMap<>(); private final CodeTypeElement topLevelClass; @@ -90,14 +89,8 @@ } private String createStaticReference(Element enclosedElement, TypeMirror type, String name) { - String qualifiedName = staticImportUsage.get(name); - if (qualifiedName == null) { - // ambiguous import - return createTypeReference(enclosedElement, type) + "." + name; - } else { - // import declared and not ambiguous - return name; - } + // ambiguous import + return createTypeReference(enclosedElement, type) + "." + name; } private String createWildcardName(Element enclosedElement, WildcardType type) { @@ -150,7 +143,6 @@ Set<CodeImport> imports = new HashSet<>(); imports.addAll(generateImports(classImportUsage)); - imports.addAll(generateStaticImports(staticImportUsage)); return imports; } @@ -218,31 +210,6 @@ } } - private Set<CodeImport> generateStaticImports(Map<String, String> toGenerate) { - Set<String> autoImportedStaticTypes = new HashSet<>(); - - // if type is declared inside a super type of this class -> no import - autoImportedStaticTypes.add(getQualifiedName(topLevelClass)); - autoImportedStaticTypes.addAll(getQualifiedSuperTypeNames(topLevelClass)); - - TreeSet<CodeImport> importObjects = new TreeSet<>(); - for (String symbol : toGenerate.keySet()) { - String qualifiedName = toGenerate.get(symbol); - if (qualifiedName == null) { - // ambiguous - continue; - } - // not not import - if (autoImportedStaticTypes.contains(qualifiedName)) { - continue; - } - - importObjects.add(new CodeImport(qualifiedName, symbol, true)); - } - - return importObjects; - } - private abstract static class TypeReferenceVisitor extends CodeElementScanner<Void, Void> { @Override @@ -414,12 +381,12 @@ @Override public void visitStaticFieldReference(Element enclosedType, TypeMirror type, String elementName) { - registerSymbol(staticImportUsage, ElementUtils.getQualifiedName(type), elementName); + visitTypeReference(enclosedType, type); } @Override public void visitStaticMethodReference(Element enclosedType, TypeMirror type, String elementName) { - registerSymbol(staticImportUsage, ElementUtils.getQualifiedName(type), elementName); + visitTypeReference(enclosedType, type); } @Override