本文整理汇总了Java中javax.lang.model.element.Name类的典型用法代码示例。如果您正苦于以下问题:Java Name类的具体用法?Java Name怎么用?Java Name使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Name类属于javax.lang.model.element包,在下文中一共展示了Name类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: isInjectionTarget
import javax.lang.model.element.Name; //导入依赖的package包/类
public static boolean isInjectionTarget(CompilationController controller, TypeElement typeElement) {
FileObject fo = controller.getFileObject();
Project project = FileOwnerQuery.getOwner(fo);
if (ElementKind.INTERFACE != typeElement.getKind()) {
List<? extends AnnotationMirror> annotations = typeElement.getAnnotationMirrors();
boolean found = false;
for (AnnotationMirror m : annotations) {
Name qualifiedName = ((TypeElement) m.getAnnotationType().asElement()).getQualifiedName();
if (qualifiedName.contentEquals("javax.jws.WebService")) {
//NOI18N
found = true;
break;
}
if (qualifiedName.contentEquals("javax.jws.WebServiceProvider")) {
//NOI18N
found = true;
break;
}
}
if (found) {
return true;
}
}
return false;
}
示例3: visitName
import javax.lang.model.element.Name; //导入依赖的package包/类
/**
* Helper method for import declarations, names, and qualified names.
*/
private void visitName(Tree node) {
Deque<Name> stack = new ArrayDeque<>();
for (; node instanceof MemberSelectTree; node = ((MemberSelectTree) node).getExpression()) {
stack.addFirst(((MemberSelectTree) node).getIdentifier());
}
stack.addFirst(((IdentifierTree) node).getName());
boolean first = true;
for (Name name : stack) {
if (!first) {
token(".");
}
token(name.toString());
first = false;
}
}
示例4: visitDocComment
import javax.lang.model.element.Name; //导入依赖的package包/类
@Override
public Void visitDocComment(DocCommentTree node, List<ErrorDescription> errors) {
DocTreePath currentDocPath = getCurrentPath();
Void value = super.visitDocComment(node, errors);
DocSourcePositions sp = (DocSourcePositions) javac.getTrees().getSourcePositions();
while (!tagStack.isEmpty()) {
StartElementTree startTree = tagStack.pop();
Name tagName = startTree.getName();
HtmlTag tag = HtmlTag.get(tagName);
if (tag.endKind == HtmlTag.EndKind.REQUIRED) {
int s = (int) sp.getStartPosition(javac.getCompilationUnit(), currentDocPath.getDocComment(), startTree);
int e = (int) sp.getEndPosition(javac.getCompilationUnit(), currentDocPath.getDocComment(), startTree);
errors.add(ErrorDescriptionFactory.forSpan(ctx, s, e, TAG_START_UNMATCHED(tagName)));
}
}
return value;
}
示例5: before
import javax.lang.model.element.Name; //导入依赖的package包/类
@Before
public void before() {
mockedDataClassBuilderAnnotation = mock(DataClassBuilder.class);
mockedProcessingEnv = mock(ProcessingEnvironment.class);
mockedTypeElement = mock(TypeElement.class);
when(mockedDataClassBuilderAnnotation.name()).thenReturn("");
when(mockedTypeElement.getAnnotation(DataClassBuilder.class)).thenReturn(mockedDataClassBuilderAnnotation);
mockedElementUtils = mock(Elements.class);
when(mockedProcessingEnv.getElementUtils()).thenReturn(mockedElementUtils);
PackageElement mockedPackageElement = mock(PackageElement.class);
when(mockedElementUtils.getPackageOf(any(Element.class))).thenReturn(mockedPackageElement);
Name mockedQualifiedName = mock(Name.class);
when(mockedPackageElement.getQualifiedName()).thenReturn(mockedQualifiedName);
when(mockedQualifiedName.toString()).thenReturn("eu.rsulkowski.test");
dataClassBuilderDescriptor = new DataClassBuilderDescriptor(mockedProcessingEnv, mockedTypeElement);
}
示例6: ignoreNonInlineTag
import javax.lang.model.element.Name; //导入依赖的package包/类
boolean ignoreNonInlineTag(DocTree dtree) {
Name name = null;
if (dtree.getKind() == Kind.START_ELEMENT) {
StartElementTree setree = (StartElementTree)dtree;
name = setree.getName();
} else if (dtree.getKind() == Kind.END_ELEMENT) {
EndElementTree eetree = (EndElementTree)dtree;
name = eetree.getName();
}
if (name != null) {
com.sun.tools.doclint.HtmlTag htmlTag = com.sun.tools.doclint.HtmlTag.get(name);
if (htmlTag != null &&
htmlTag.blockType != com.sun.tools.doclint.HtmlTag.BlockType.INLINE) {
return true;
}
}
return false;
}
示例7: check
import javax.lang.model.element.Name; //导入依赖的package包/类
@Override
void check(TreePath path, Name name) throws Exception {
String raw = trees.getDocComment(path);
String normRaw = normalize(raw);
StringWriter out = new StringWriter();
DocPretty dp = new DocPretty(out);
dp.print(trees.getDocCommentTree(path));
String pretty = out.toString();
if (!pretty.equals(normRaw)) {
error("mismatch");
System.err.println("*** expected:");
System.err.println(normRaw.replace(" ", "_"));
System.err.println("*** found:");
System.err.println(pretty.replace(" ", "_"));
// throw new Error();
}
}
示例8: getAvailableVariables
import javax.lang.model.element.Name; //导入依赖的package包/类
private Set<Name> getAvailableVariables() {
if (this.availableVariables == null) {
PreconditionsChecker.VariablesVisitor treeVariableVisitor = new PreconditionsChecker.VariablesVisitor(new TreePath(this.workingCopy.getCompilationUnit()));
if (this.correspondingTree.getKind() == Tree.Kind.VARIABLE) {
treeVariableVisitor.scan(((VariableTree) correspondingTree).getInitializer(), this.workingCopy.getTrees());
this.availableVariables = buildAvailables(treeVariableVisitor);
this.availableVariables.add(((VariableTree) correspondingTree).getName());
} else {
treeVariableVisitor.scan(correspondingTree, this.workingCopy.getTrees());
this.availableVariables = buildAvailables(treeVariableVisitor);
}
}
//If the operation is a filter, then it only makes available what it gets
//if needed is empty, it can pull anything needed from upstream.
if (this.opType == OperationType.FILTER) {
return this.getNeededVariables();
}
return this.availableVariables;
}
示例9: declaredVariables
import javax.lang.model.element.Name; //导入依赖的package包/类
private Set<Name> declaredVariables(TreePath where) {
Set<Name> result = new HashSet<Name>();
Iterable<? extends Tree> statements;
if (where.getLeaf().getKind() == Tree.Kind.BLOCK) {
statements = ((BlockTree) where.getLeaf()).getStatements();
} else {
statements = Collections.singletonList(where.getLeaf());
}
for (Tree t : statements) {
if (t.getKind() == Tree.Kind.VARIABLE) {
result.add(((VariableTree) t).getName());
}
}
return result;
}
示例10: validateHtml4Attrs
import javax.lang.model.element.Name; //导入依赖的package包/类
private void validateHtml4Attrs(AttributeTree tree, Name name, AttrKind k) {
switch (k) {
case ALL:
case HTML4:
break;
case INVALID:
env.messages.error(HTML, tree, "dc.attr.unknown", name);
break;
case OBSOLETE:
env.messages.warning(ACCESSIBILITY, tree, "dc.attr.obsolete", name);
break;
case USE_CSS:
env.messages.warning(ACCESSIBILITY, tree, "dc.attr.obsolete.use.css", name);
break;
case HTML5:
env.messages.error(HTML, tree, "dc.attr.not.supported.html4", name);
break;
}
}
示例11: target2String
import javax.lang.model.element.Name; //导入依赖的package包/类
public static String target2String(TypeElement target) {
final Name qualifiedName = target.getQualifiedName(); //#130759
if (qualifiedName == null) {
Logger.getLogger(Utilities.class.getName()).warning("Target qualified name could not be resolved."); //NOI18N
return ""; //NOI18N
} else {
String qnString = qualifiedName.toString();
if (qnString.length() == 0) {
//probably an anonymous class
qnString = target.asType().toString();
}
try {
qnString = XMLUtil.toElementContent(qnString);
} catch (CharConversionException ex) {
Logger.getLogger(Utilities.class.getName()).log(Level.FINE, null, ex);
}
return qnString;
}
}
示例12: getJavadocSafeName
import javax.lang.model.element.Name; //导入依赖的package包/类
/**
* Returns a safe String to use in a Javadoc that will function in a link.
*
* <p>This method exists because by Javadoc doesn't handle type parameters({@literal <T>}
* in {@literal RequestOptions<T>} for example).
*/
private TypeName getJavadocSafeName(Element element) {
Types typeUtils = processingEnv.getTypeUtils();
TypeMirror type = element.asType();
if (typeUtils.asElement(type) == null) {
// If there is no Element, it's a primitive and can't have additional types, so we're done.
return ClassName.get(element.asType());
}
Name simpleName = typeUtils.asElement(type).getSimpleName();
return ClassName.bestGuess(simpleName.toString());
}
示例13: generateNodeMethod
import javax.lang.model.element.Name; //导入依赖的package包/类
private MethodSpec generateNodeMethod(Name superName, String packageName) {
return MethodSpec.methodBuilder("node") //
.addAnnotation(Override.class)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL) //
.returns(ClassName.get(packageName, "Node_" + superName))
.addCode("return new Node_$L(this);\n", superName)
.build();
}
示例14: 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;
}
示例15: getInfo
import javax.lang.model.element.Name; //导入依赖的package包/类
/**
* Extract {@link PrimitiveData} information about the class.
*
* @param classFQN
* @param annotation
* @return
*/
private PrimitiveData getInfo(String classFQN, TypeElement classType, AnnotationMirror annotation) {
String name = null;
String description = null;
List<String> tags = Collections.EMPTY_LIST;
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotation.getElementValues().entrySet()) {
// name
Name entryName = entry.getKey().getSimpleName();
AnnotationValue entryValue = entry.getValue();
if (entryName.contentEquals("name")) {
name = getAnnotationValue(String.class, classFQN, "name", entryValue);
} else if (entryName.contentEquals("description")) {
description = getAnnotationValue(String.class, classFQN, "description", entryValue);
} else if (entryName.contentEquals("tags")) {
List<AnnotationValue> tagList = getAnnotationValue(List.class, classFQN, "tags", entryValue);
if (tagList != null) {
tags = new ArrayList<String>(tagList.size());
for (AnnotationValue tagValue : tagList) {
String tag = getAnnotationValue(String.class, classFQN, "tags", tagValue);
if (tag != null) {
tags.add(tag);
}
}
}
}
}
Set<ParamInfo> primitiveParams = getAnnotatedParams(classType);
return new PrimitiveData(classFQN, name, description, tags.toArray(new String[tags.size()]), primitiveParams);
}