1 11 12 package org.eclipse.jdt.internal.ui.javaeditor; 13 14 import org.eclipse.jdt.core.dom.CompilationUnit; 15 import org.eclipse.jdt.core.dom.Expression; 16 import org.eclipse.jdt.core.dom.IBinding; 17 import org.eclipse.jdt.core.dom.SimpleName; 18 19 22 public final class SemanticToken { 23 24 25 private SimpleName fNode; 26 private Expression fLiteral; 27 28 29 private IBinding fBinding; 30 31 private boolean fIsBindingResolved= false; 32 33 34 private CompilationUnit fRoot; 35 private boolean fIsRootResolved= false; 36 37 40 public IBinding getBinding() { 41 if (!fIsBindingResolved) { 42 fIsBindingResolved= true; 43 if (fNode != null) 44 fBinding= fNode.resolveBinding(); 45 } 46 47 return fBinding; 48 } 49 50 53 public SimpleName getNode() { 54 return fNode; 55 } 56 57 60 public Expression getLiteral() { 61 return fLiteral; 62 } 63 64 67 public CompilationUnit getRoot() { 68 if (!fIsRootResolved) { 69 fIsRootResolved= true; 70 fRoot= (CompilationUnit) (fNode != null ? fNode : fLiteral).getRoot(); 71 } 72 73 return fRoot; 74 } 75 76 84 void update(SimpleName node) { 85 clear(); 86 fNode= node; 87 } 88 89 97 void update(Expression literal) { 98 clear(); 99 fLiteral= literal; 100 } 101 102 108 void clear() { 109 fNode= null; 110 fLiteral= null; 111 fBinding= null; 112 fIsBindingResolved= false; 113 fRoot= null; 114 fIsRootResolved= false; 115 } 116 } 117 | Popular Tags |