本文整理汇总了Java中javax.lang.model.element.Name.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Name.equals方法的具体用法?Java Name.equals怎么用?Java Name.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.lang.model.element.Name
的用法示例。
在下文中一共展示了Name.equals方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkParamDeclared
import javax.lang.model.element.Name; //导入方法依赖的package包/类
@NbBundle.Messages({"# {0} - @param name", "UNKNOWN_TYPEPARAM_DESC=Unknown @param: {0}",
"# {0} - @param name", "DUPLICATE_PARAM_DESC=Duplicate @param name: {0}"})
private void checkParamDeclared(ParamTree tree, List<? extends Element> list,
DocTreePathHandle dtph, int start, int end, List<ErrorDescription> errors) {
Name name = tree.getName().getName();
boolean found = false;
for (Element e: list) {
if(ctx.isCanceled()) { return; }
if (name.equals(e.getSimpleName())) {
if(!foundParams.add(e)) {
errors.add(ErrorDescriptionFactory.forSpan(ctx, start, end, DUPLICATE_PARAM_DESC(name), new RemoveTagFix(dtph, "@param").toEditorFix())); // NOI18N
}
found = true;
}
}
if (!found) {
errors.add(ErrorDescriptionFactory.forSpan(ctx, start, end, UNKNOWN_TYPEPARAM_DESC(name), new RemoveTagFix(dtph, "@param").toEditorFix())); //NOI18N
}
}
示例2: ambiguousNames
import javax.lang.model.element.Name; //导入方法依赖的package包/类
private static Set<String> ambiguousNames(Types typeUtils, Set<TypeMirror> types) {
Set<String> ambiguous = new HashSet<String>();
Map<String, Name> simpleNamesToQualifiedNames = new HashMap<String, Name>();
for (TypeMirror type : types) {
if (type.getKind() == TypeKind.ERROR) {
throw new MissingTypeException();
}
String simpleName = typeUtils.asElement(type).getSimpleName().toString();
/*
* Compare by qualified names, because in Eclipse JDT, if Java 8 type annotations are used,
* the same (unannotated) type may appear multiple times in the Set<TypeMirror>.
* TODO(emcmanus): investigate further, because this might cause problems elsewhere.
*/
Name qualifiedName = ((TypeElement)typeUtils.asElement(type)).getQualifiedName();
Name previous = simpleNamesToQualifiedNames.put(simpleName, qualifiedName);
if (previous != null && !previous.equals(qualifiedName)) {
ambiguous.add(simpleName);
}
}
return ambiguous;
}
示例3: ambiguousNames
import javax.lang.model.element.Name; //导入方法依赖的package包/类
private static Set<String> ambiguousNames(Types typeUtils, Set<TypeMirror> types) {
Set<String> ambiguous = new HashSet<String>();
Map<String, Name> simpleNamesToQualifiedNames = new HashMap<String, Name>();
for (TypeMirror type : types) {
if (type.getKind() == TypeKind.ERROR) {
throw new MissingTypeException();
}
String simpleName = typeUtils.asElement(type).getSimpleName().toString();
/*
* Compare by qualified names, because in Eclipse JDT, if Java 8 type annotations are used,
* the same (unannotated) type may appear multiple times in the Set<TypeMirror>.
* TODO(emcmanus): investigate further, because this might cause problems elsewhere.
*/
Name qualifiedName = ((TypeElement)typeUtils.asElement(type)).getQualifiedName();
Name previous = simpleNamesToQualifiedNames.put(simpleName, qualifiedName);
if (previous != null && !previous.equals(qualifiedName)) {
ambiguous.add(simpleName);
}
}
return ambiguous;
}
示例4: needLongName
import javax.lang.model.element.Name; //导入方法依赖的package包/类
protected final boolean needLongName(ExecutableElement method,
TypeElement clazz) {
Name methodName = method.getSimpleName();
for (ExecutableElement memberMethod: methods) {
if ((memberMethod != method) &&
memberMethod.getModifiers().contains(Modifier.NATIVE) &&
(methodName.equals(memberMethod.getSimpleName())))
return true;
}
return false;
}
示例5: computeFixes
import javax.lang.model.element.Name; //导入方法依赖的package包/类
protected static Fix computeFixes(CompilationInfo info, TreePath treePath, int[] bounds, int[] kind, String[] simpleName) {
if (treePath.getLeaf().getKind() != Kind.MEMBER_SELECT) {
return null;
}
MemberSelectTree mst = (MemberSelectTree)treePath.getLeaf();
Tree expression = mst.getExpression();
TreePath expr = new TreePath(treePath, expression);
TypeMirror tm = info.getTrees().getTypeMirror(expr);
if (!Utilities.isValidType(tm)) {
return null;
}
Element el = info.getTypes().asElement(tm);
if (el == null || (!el.getKind().isClass() && !el.getKind().isInterface())) {
return null;
}
TypeElement type = (TypeElement)el;
if (isError(type)) {
return null;
}
Name idName = null;
if (expression.getKind() == Kind.MEMBER_SELECT) {
MemberSelectTree exprSelect = (MemberSelectTree)expression;
idName = exprSelect.getIdentifier();
}
if (expression.getKind() == Kind.IDENTIFIER) {
IdentifierTree idt = (IdentifierTree)expression;
idName = idt.getName();
}
if (idName != null) {
if (idName.equals(type.getSimpleName())) {
return null;
}
if (idName.equals(type.getQualifiedName())) {
return null;
}
}
Element used = info.getTrees().getElement(treePath);
if (used == null || !used.getModifiers().contains(Modifier.STATIC)) {
return null;
}
if (isError(used)) {
return null;
}
if (used.getKind().isField()) {
kind[0] = 0;
} else {
if (used.getKind() == ElementKind.METHOD) {
kind[0] = 1;
} else {
kind[0] = 2;
}
}
simpleName[0] = used.getSimpleName().toString();
return new FixImpl(info, expr, type).toEditorFix();
}