本文整理汇总了Java中javax.lang.model.element.Element.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Element.equals方法的具体用法?Java Element.equals怎么用?Java Element.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.lang.model.element.Element
的用法示例。
在下文中一共展示了Element.equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitImport
import javax.lang.model.element.Element; //导入方法依赖的package包/类
@Override
public Void visitImport(ImportTree node, Stack<Tree> p) {
if (node.isStatic() && toFind.getModifiers().contains(Modifier.STATIC)) {
Tree qualIdent = node.getQualifiedIdentifier();
if (qualIdent.getKind() == Kind.MEMBER_SELECT) {
MemberSelectTree mst = (MemberSelectTree) qualIdent;
if (toFind.getSimpleName().contentEquals(mst.getIdentifier())) {
Element el = info.getTrees().getElement(new TreePath(getCurrentPath(), mst.getExpression()));
if (el != null && el.equals(toFind.getEnclosingElement())) {
Token<JavaTokenId> t = Utilities.getToken(info, doc, new TreePath(getCurrentPath(), mst));
if (t != null)
usages.add(t);
}
}
}
}
return super.visitImport(node, p);
}
示例2: addIfMatch
import javax.lang.model.element.Element; //导入方法依赖的package包/类
private void addIfMatch(TreePath path, Tree tree, Element elementToFind) {
if (cc.getTreeUtilities().isSynthetic(path)) {
return;
}
Element el = cc.getTrees().getElement(path);
if (el==null) {
return;
}
if (elementToFind.getKind() == ElementKind.METHOD && el.getKind() == ElementKind.METHOD) {
if (el.equals(elementToFind) || cc.getElements().overrides(((ExecutableElement) el), (ExecutableElement) elementToFind, (TypeElement) elementToFind.getEnclosingElement())) {
addUsage(getCurrentPath());
}
} else if (el.equals(elementToFind)) {
addUsage(getCurrentPath());
}
}
示例3: isMatch
import javax.lang.model.element.Element; //导入方法依赖的package包/类
private boolean isMatch(Element element, Element elementToFind) {
if(element == null) {
return false;
}
if(allMethods == null || element.getKind() != ElementKind.METHOD) {
return element.equals(elementToFind);
} else {
for (ElementHandle<ExecutableElement> mh: allMethods) {
ExecutableElement baseMethod = mh.resolve(workingCopy);
if (baseMethod==null) {
Logger.getLogger("org.netbeans.modules.refactoring.java").log(Level.INFO, "DeleteTransformer cannot resolve {0}", mh);
continue;
}
if (baseMethod.equals(element) || workingCopy.getElements().overrides((ExecutableElement)element, baseMethod, workingCopy.getElementUtilities().enclosingTypeElement(baseMethod))) {
return true;
}
}
}
return false;
}
示例4: visitReference
import javax.lang.model.element.Element; //导入方法依赖的package包/类
@Override
public DocTree visitReference(ReferenceTree node, Element p) {
DocTrees trees = info.getDocTrees();
Element el = trees.getElement(getCurrentPath());
if (el != null && el.equals(toFind)) {
int[] span = treeUtils.findNameSpan(getCurrentPath().getDocComment(), node);
if(span != null) {
try {
MutablePositionRegion region = createRegion(doc, span[0], span[1]);
usages.add(region);
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
}
}
return super.visitReference(node, p);
}
示例5: visitIdentifier
import javax.lang.model.element.Element; //导入方法依赖的package包/类
@Override
public DocTree visitIdentifier(com.sun.source.doctree.IdentifierTree node, Element p) {
DocTrees trees = info.getDocTrees();
Element el = trees.getElement(getCurrentPath());
if (el != null && el.equals(toFind)) {
DocSourcePositions sp = trees.getSourcePositions();
CompilationUnitTree cut = info.getCompilationUnit();
DocCommentTree docComment = getCurrentPath().getDocComment();
long start = sp.getStartPosition(cut, docComment, node);
long end = sp.getEndPosition(cut, docComment, node);
if(start != Diagnostic.NOPOS && end != Diagnostic.NOPOS) {
try {
MutablePositionRegion region = createRegion(doc, (int)start, (int)end);
usages.add(region);
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
}
}
return super.visitIdentifier(node, p);
}
示例6: uprootAccessPaths
import javax.lang.model.element.Element; //导入方法依赖的package包/类
/**
* Takes the Access Paths rooted at specific locals in this NullnessStore and translates them to
* paths rooted at different/renamed local variables.
*
* <p>This method is used to patch-around the paths inter-procedurally when handling certain
* libraries. For example, by {@code handlers.RxNullabilityPropagator} to translate access paths
* relative to the argument of a filter(...) method, to paths relative to the argument of a
* map(...) method in a filter(...).map(...) chain pattern.
*
* @param localVarTranslations A map from local variable nodes to local variable nodes, indicating
* the desired re-rooting / re-naming.
* @return A store containing only those access paths in {@code this} which are relative to
* variables in the domain of {@code localVarTranslations}, with each access path re-rooted to
* be relative to the corresponding local variable in the co-domain of the map.
*/
public NullnessStore<V> uprootAccessPaths(
Map<LocalVariableNode, LocalVariableNode> localVarTranslations) {
NullnessStore.Builder<V> nullnessBuilder = NullnessStore.<V>empty().toBuilder();
for (AccessPath ap : contents.keySet()) {
if (ap.getRoot().isReceiver()) {
continue;
}
Element varElement = ap.getRoot().getVarElement();
for (LocalVariableNode fromVar : localVarTranslations.keySet()) {
if (varElement.equals(fromVar.getElement())) {
LocalVariableNode toVar = localVarTranslations.get(fromVar);
AccessPath newAP =
new AccessPath(new AccessPath.Root(toVar.getElement()), ap.getElements());
nullnessBuilder.setInformation(newAP, contents.get(ap));
}
}
}
return nullnessBuilder.build();
}
示例7: getAllMembers
import javax.lang.model.element.Element; //导入方法依赖的package包/类
private Collection<? extends Element> getAllMembers(ASTService ast, Elements elements, Element el) {
List<Element> result = new ArrayList<Element>();
result.addAll(el.getEnclosedElements());
for (Element parent : getAllSuperElements(ast, elements, el)) {
if (!el.equals(parent)) {
result.addAll(getAllMembers(ast, elements, parent));
}
}
return result;
}
示例8: addToPropertiesMap
import javax.lang.model.element.Element; //导入方法依赖的package包/类
private void addToPropertiesMap(Element propertyMethod,
Element commentSource) {
if (null == propertyMethod || null == commentSource) {
return;
}
DocCommentTree docTree = utils.getDocCommentTree(propertyMethod);
/* The second condition is required for the property buckets. In
* this case the comment is at the property method (not at the field)
* and it needs to be listed in the map.
*/
if ((docTree == null) || propertyMethod.equals(commentSource)) {
classPropertiesMap.put(propertyMethod, commentSource);
}
}
示例9: classLanguage
import javax.lang.model.element.Element; //导入方法依赖的package包/类
private EgLanguage classLanguage(Element el) {
if (el.equals(classElement))
return defaultLanguage; // Typical case
EgLanguage lang = languageForClassName.get(AnnotationCollector.className(el));
return (lang==null)
? classLanguage(el.getEnclosingElement()) // Java doesn't actually support tail recursion
: lang;
}
示例10: getAccessModifiers
import javax.lang.model.element.Element; //导入方法依赖的package包/类
public static Visibility getAccessModifiers(@NonNull CompilationInfo info, @NullAllowed TypeElement source, @NonNull TypeElement target) {
if (target.getKind().isInterface()) {
return Visibility.PUBLIC;
}
TypeElement outterMostSource = source != null ? info.getElementUtilities().outermostTypeElement(source) : null;
TypeElement outterMostTarget = info.getElementUtilities().outermostTypeElement(target);
if (outterMostTarget.equals(outterMostSource)) {
return Visibility.PRIVATE;
}
Element sourcePackage;
if (outterMostSource != null) {
sourcePackage = outterMostSource.getEnclosingElement();
} else if (info.getCompilationUnit().getPackageName() != null) {
sourcePackage = info.getTrees().getElement(new TreePath(new TreePath(info.getCompilationUnit()), info.getCompilationUnit().getPackageName()));
} else {
sourcePackage = info.getElements().getPackageElement("");
}
Element targetPackage = outterMostTarget.getEnclosingElement();
if (sourcePackage != null && sourcePackage.equals(targetPackage)) {
return Visibility.PACKAGE_PRIVATE;
}
//TODO: protected?
return Visibility.PUBLIC;
}
示例11: getTargetType
import javax.lang.model.element.Element; //导入方法依赖的package包/类
/**
* Returns the target type of the specified type element representing a parameter converter class.
* @param converterElement
* @throws ModelException
*/
String getTargetType(TypeElement converterElement) throws ModelException {
for (AnnotationMirror am : converterElement.getAnnotationMirrors()) {
Element ae = typeUtils.asElement(am.getAnnotationType());
if (ae.equals(converterAnnotation))
for (Map.Entry<? extends ExecutableElement,? extends AnnotationValue> e : am.getElementValues().entrySet())
if ("targetType".equals(e.getKey().getSimpleName().toString()))
return e.getValue().toString();
}
throw new ModelException("cannot read target type for converter: " + converterElement.getQualifiedName());
}
示例12: hasResultType
import javax.lang.model.element.Element; //导入方法依赖的package包/类
private boolean hasResultType(ExecutableElement ee, Element typeElement) {
TypeMirror returnType = ee.getReturnType();
Element returnTypeElement = processingEnv.getTypeUtils().asElement(
returnType);
return returnTypeElement.equals(typeElement);
}
示例13: createInterval
import javax.lang.model.element.Element; //导入方法依赖的package包/类
public static Interval createInterval(TreePath tp, CompilationInfo info, Interval root, Interval p, FileObject parentFile) {
Tree t = tp.getLeaf();
long start = info.getTrees().getSourcePositions().getStartPosition(info.getCompilationUnit(), t);
long end = info.getTrees().getSourcePositions().getEndPosition(info.getCompilationUnit(), t);
Element current = info.getTrees().getElement(tp);
Tree.Kind kind = tp.getLeaf().getKind();
if (!TreeUtilities.CLASS_TREE_KINDS.contains(kind) && kind != Tree.Kind.METHOD) {
if (tp.getParentPath() == null || tp.getParentPath().getLeaf().getKind() == Tree.Kind.COMPILATION_UNIT) {
//xxx: rather workaround. should be fixed better.
return null;
} else {
return createInterval(tp.getParentPath(), info, root, p, parentFile);
}
}
Interval i = null;
if (root != null) {
Interval o = root.get(start);
if (o != null && current != null && current.equals(o.item.resolveElement(info))) {
// Update start/end, from/to
o.from = start;
o.to = end;
if (p != null) {
o.subintervals.add(p);
}
return null;
}
}
if (i == null) {
i = new Interval();
}
if (i.from != start) {
i.from = start;
i.to = end;
ElementGrip currentHandle2 = new ElementGrip(tp, info);
i.item = currentHandle2;
}
if (p != null) {
i.subintervals.add(p);
}
if (tp.getParentPath().getLeaf().getKind() == Tree.Kind.COMPILATION_UNIT) {
return i;
}
return createInterval(tp.getParentPath(), info, root, i, parentFile);
}
示例14: jniType
import javax.lang.model.element.Element; //导入方法依赖的package包/类
protected final String jniType(TypeMirror t) throws Util.Exit {
TypeElement throwable = elems.getTypeElement("java.lang.Throwable");
TypeElement jClass = elems.getTypeElement("java.lang.Class");
TypeElement jString = elems.getTypeElement("java.lang.String");
Element tclassDoc = types.asElement(t);
switch (t.getKind()) {
case ARRAY: {
TypeMirror ct = ((ArrayType) t).getComponentType();
switch (ct.getKind()) {
case BOOLEAN: return "jbooleanArray";
case BYTE: return "jbyteArray";
case CHAR: return "jcharArray";
case SHORT: return "jshortArray";
case INT: return "jintArray";
case LONG: return "jlongArray";
case FLOAT: return "jfloatArray";
case DOUBLE: return "jdoubleArray";
case ARRAY:
case DECLARED: return "jobjectArray";
default: throw new Error(ct.toString());
}
}
case VOID: return "void";
case BOOLEAN: return "jboolean";
case BYTE: return "jbyte";
case CHAR: return "jchar";
case SHORT: return "jshort";
case INT: return "jint";
case LONG: return "jlong";
case FLOAT: return "jfloat";
case DOUBLE: return "jdouble";
case DECLARED: {
if (tclassDoc.equals(jString))
return "jstring";
else if (types.isAssignable(t, throwable.asType()))
return "jthrowable";
else if (types.isAssignable(t, jClass.asType()))
return "jclass";
else
return "jobject";
}
}
util.bug("jni.unknown.type");
return null; /* dead code. */
}
示例15: jniType
import javax.lang.model.element.Element; //导入方法依赖的package包/类
protected final String jniType(TypeMirror t) throws Util.Exit {
TypeElement throwable = elems.getTypeElement("java.lang.Throwable");
TypeElement jClass = elems.getTypeElement("java.lang.Class");
TypeElement jString = elems.getTypeElement("java.lang.String");
Element tclassDoc = types.asElement(t);
switch (t.getKind()) {
case ARRAY: {
TypeMirror ct = ((ArrayType) t).getComponentType();
switch (ct.getKind()) {
case BOOLEAN: return "jbooleanArray";
case BYTE: return "jbyteArray";
case CHAR: return "jcharArray";
case SHORT: return "jshortArray";
case INT: return "jintArray";
case LONG: return "jlongArray";
case FLOAT: return "jfloatArray";
case DOUBLE: return "jdoubleArray";
case ARRAY:
case DECLARED: return "jobjectArray";
default: throw new Error(ct.toString());
}
}
case VOID: return "void";
case BOOLEAN: return "jboolean";
case BYTE: return "jbyte";
case CHAR: return "jchar";
case SHORT: return "jshort";
case INT: return "jint";
case LONG: return "jlong";
case FLOAT: return "jfloat";
case DOUBLE: return "jdouble";
case DECLARED: {
if (tclassDoc.equals(jString))
return "jstring";
else if (types.isAssignable(t, throwable.asType()))
return "jthrowable";
else if (types.isAssignable(t, jClass.asType()))
return "jclass";
else
return "jobject";
}
}
util.bug("jni.unknown.type");
return null; /* dead code. */
}