本文整理汇总了Java中com.sun.tools.javac.code.Symbol.getKind方法的典型用法代码示例。如果您正苦于以下问题:Java Symbol.getKind方法的具体用法?Java Symbol.getKind怎么用?Java Symbol.getKind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.code.Symbol
的用法示例。
在下文中一共展示了Symbol.getKind方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attributeParamIdentifier
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
private Symbol attributeParamIdentifier(TreePath path, DCParam ptag) {
Symbol javadocSymbol = getElement(path);
if (javadocSymbol == null)
return null;
ElementKind kind = javadocSymbol.getKind();
List<? extends Symbol> params = List.nil();
if (kind == ElementKind.METHOD || kind == ElementKind.CONSTRUCTOR) {
MethodSymbol ee = (MethodSymbol) javadocSymbol;
params = ptag.isTypeParameter()
? ee.getTypeParameters()
: ee.getParameters();
} else if (kind.isClass() || kind.isInterface()) {
ClassSymbol te = (ClassSymbol) javadocSymbol;
params = te.getTypeParameters();
}
for (Symbol param : params) {
if (param.getSimpleName() == ptag.getName().getName()) {
return param;
}
}
return null;
}
示例2: getDescriptorElement
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
/**
* Find the element of the method descriptor associated to the functional interface.
*
* @param origin functional interface element
* @return associated method descriptor element or <code>null</code> if the <code>origin</code> is not a functional interface.
* @since 2.14
*/
public ExecutableElement getDescriptorElement(TypeElement origin) {
com.sun.tools.javac.code.Types types = com.sun.tools.javac.code.Types.instance(info.impl.getJavacTask().getContext());
if (types.isFunctionalInterface((TypeSymbol)origin)) {
Symbol sym = types.findDescriptorSymbol((TypeSymbol)origin);
if (sym != null && sym.getKind() == ElementKind.METHOD) {
return (ExecutableElement)sym;
}
}
return null;
}
示例3: matchAssignment
import com.sun.tools.javac.code.Symbol; //导入方法依赖的package包/类
@Override
public Description matchAssignment(AssignmentTree tree, VisitorState state) {
if (!matchWithinClass) {
return Description.NO_MATCH;
}
Type lhsType = ASTHelpers.getType(tree.getVariable());
if (lhsType != null && lhsType.isPrimitive()) {
return doUnboxingCheck(state, tree.getExpression());
}
Symbol assigned = ASTHelpers.getSymbol(tree.getVariable());
if (assigned == null || assigned.getKind() != ElementKind.FIELD) {
// not a field of nullable type
return Description.NO_MATCH;
}
if (Nullness.hasNullableAnnotation(assigned)) {
// field already annotated
return Description.NO_MATCH;
}
ExpressionTree expression = tree.getExpression();
if (mayBeNullExpr(state, expression)) {
String message = "assigning @Nullable expression to @NonNull field";
return createErrorDescriptionForNullAssignment(
MessageTypes.ASSIGN_FIELD_NULLABLE, tree, message, expression, state.getPath());
}
return Description.NO_MATCH;
}