Mercurial > hg > truffle
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/FixWarningsVisitor.java @ 16786:45c8f64978d6
Truffle-DSL: initial cleanups for code sharing with the new graal annotation processor.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 12 Aug 2014 17:21:06 +0200 |
parents | 23415229349b |
children | 62cfffca9be2 |
comparison
equal
deleted
inserted
replaced
16785:af3da93ea934 | 16786:45c8f64978d6 |
---|---|
26 import static javax.lang.model.element.Modifier.*; | 26 import static javax.lang.model.element.Modifier.*; |
27 | 27 |
28 import java.io.*; | 28 import java.io.*; |
29 import java.util.*; | 29 import java.util.*; |
30 | 30 |
31 import javax.annotation.processing.*; | |
31 import javax.lang.model.element.*; | 32 import javax.lang.model.element.*; |
32 import javax.lang.model.type.*; | 33 import javax.lang.model.type.*; |
33 | 34 |
34 import com.oracle.truffle.dsl.processor.*; | |
35 import com.oracle.truffle.dsl.processor.java.*; | 35 import com.oracle.truffle.dsl.processor.java.*; |
36 import com.oracle.truffle.dsl.processor.java.model.*; | 36 import com.oracle.truffle.dsl.processor.java.model.*; |
37 | 37 |
38 public class FixWarningsVisitor extends CodeElementScanner<Void, Void> { | 38 public class FixWarningsVisitor extends CodeElementScanner<Void, Void> { |
39 | 39 |
40 private final Set<String> symbolsUsed = new HashSet<>(); | 40 private final Set<String> symbolsUsed = new HashSet<>(); |
41 | 41 |
42 private final ProcessorContext context; | 42 private final ProcessingEnvironment processingEnv; |
43 private final DeclaredType unusedAnnotation; | 43 private final DeclaredType unusedAnnotation; |
44 private final DeclaredType overrideType; | 44 private final DeclaredType overrideType; |
45 | 45 |
46 public FixWarningsVisitor(ProcessorContext context, DeclaredType unusedAnnotation, DeclaredType overrideType) { | 46 public FixWarningsVisitor(ProcessingEnvironment processingEnv, DeclaredType unusedAnnotation, DeclaredType overrideType) { |
47 this.context = context; | 47 this.processingEnv = processingEnv; |
48 this.unusedAnnotation = unusedAnnotation; | 48 this.unusedAnnotation = unusedAnnotation; |
49 this.overrideType = overrideType; | 49 this.overrideType = overrideType; |
50 } | 50 } |
51 | 51 |
52 @Override | 52 @Override |
54 List<TypeElement> superTypes = ElementUtils.getSuperTypes(e); | 54 List<TypeElement> superTypes = ElementUtils.getSuperTypes(e); |
55 for (TypeElement type : superTypes) { | 55 for (TypeElement type : superTypes) { |
56 String qualifiedName = ElementUtils.getQualifiedName(type); | 56 String qualifiedName = ElementUtils.getQualifiedName(type); |
57 if (qualifiedName.equals(Serializable.class.getCanonicalName())) { | 57 if (qualifiedName.equals(Serializable.class.getCanonicalName())) { |
58 if (!e.containsField("serialVersionUID")) { | 58 if (!e.containsField("serialVersionUID")) { |
59 e.add(new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), context.getType(long.class), "serialVersionUID", "1L")); | 59 e.add(new CodeVariableElement(modifiers(PRIVATE, STATIC, FINAL), ElementUtils.getType(processingEnv, long.class), "serialVersionUID", "1L")); |
60 } | 60 } |
61 break; | 61 break; |
62 } | 62 } |
63 } | 63 } |
64 | 64 |