< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java

Print this page

        

@@ -43,10 +43,11 @@
 import static javax.lang.model.util.ElementFilter.methodsIn;
 
 import com.sun.source.util.JavacTask;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Accessors.Kind;
 import com.sun.tools.javac.code.Attribute.Compound;
 import com.sun.tools.javac.code.Directive.ExportsDirective;
 import com.sun.tools.javac.code.Directive.ExportsFlag;
 import com.sun.tools.javac.code.Directive.OpensDirective;
 import com.sun.tools.javac.code.Directive.OpensFlag;

@@ -798,6 +799,25 @@
     }
 
     public void newRound() {
         resultCache.clear();
     }
+
+    @Override
+    public ExecutableElement getterFor(VariableElement variableElement) {
+        return accessorFor(Kind.GET, variableElement);
+    }
+
+    @Override
+    public ExecutableElement setterFor(VariableElement variableElement) {
+        return accessorFor(Kind.SET, variableElement);
+    }
+
+    private ExecutableElement accessorFor(Accessors.Kind kind, VariableElement variableElement) {
+        for (Pair<Accessors.Kind, MethodSymbol> accessor : ((VarSymbol)variableElement).accessors) {
+            if (accessor.fst == kind) {
+                return accessor.snd;
+            }
+        }
+        return null;
+    }
 }
< prev index next >