当前位置: 首页>>代码示例>>Java>>正文


Java ElementKind.PARAMETER属性代码示例

本文整理汇总了Java中javax.lang.model.element.ElementKind.PARAMETER属性的典型用法代码示例。如果您正苦于以下问题:Java ElementKind.PARAMETER属性的具体用法?Java ElementKind.PARAMETER怎么用?Java ElementKind.PARAMETER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.lang.model.element.ElementKind的用法示例。


在下文中一共展示了ElementKind.PARAMETER属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitCompilationUnit

@Override
public Void visitCompilationUnit(CompilationUnitTree node, Void p) {
    if (!searchComment) {
        return super.visitCompilationUnit(node, p);
    }

    if (toFind.getKind() == ElementKind.PARAMETER) {
        renameParameterInMethodComments(toFind);
    } else {
        String originalName = toFind.getSimpleName().toString();
        if (originalName!=null) {
            TokenSequence<JavaTokenId> ts = info.getTokenHierarchy().tokenSequence(JavaTokenId.language());

            while (ts.moveNext()) {
                Token<JavaTokenId> t = ts.token();
                
                if (isComment(t)) {
                    findAllInComment(t.text().toString(), ts.offset(), originalName);
                }
            }
        }
    }
    return super.visitCompilationUnit(node, p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:FindLocalUsagesQuery.java

示例2: checkConstantExpression

static boolean checkConstantExpression(final CompilationInfo info, TreePath path) {
    InstanceRefFinder finder = new InstanceRefFinder(info, path) {
        @Override
        public Object visitIdentifier(IdentifierTree node, Object p) {
            Element el = info.getTrees().getElement(getCurrentPath());
            if (el == null || el.asType() == null || el.asType().getKind() == TypeKind.ERROR) {
                return null;
            }
            if (el.getKind() == ElementKind.LOCAL_VARIABLE || el.getKind() == ElementKind.PARAMETER) {
                throw new StopProcessing();
            } else if (el.getKind() == ElementKind.FIELD) {
                if (!el.getModifiers().contains(Modifier.FINAL)) {
                    throw new StopProcessing();
                }
            }
            return super.visitIdentifier(node, p);
        }
    };
    try {
        finder.process();
        return  !(finder.containsInstanceReferences() || finder.containsLocalReferences() || finder.containsReferencesToSuper());
    } catch (StopProcessing e) {
        return false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:IntroduceConstantFix.java

示例3: findMethodsWithSpyglassAnnotations

private Set<ExecutableElement> findMethodsWithSpyglassAnnotations(final RoundEnvironment roundEnvironment) {
	final Set<ExecutableElement> methods = new HashSet<>();

	for (final Class<? extends Annotation> annoType : SUPPORTED_ANNOTATIONS) {
		for (final Element foundElement : roundEnvironment.getElementsAnnotatedWith(annoType)) {
			if (foundElement.getKind() == ElementKind.METHOD) {
				methods.add((ExecutableElement) foundElement);
			} else if (foundElement.getKind() == ElementKind.PARAMETER) {
				methods.add((ExecutableElement) foundElement.getEnclosingElement());
			} else {
				throw new RuntimeException("A Spyglass annotation was somehow applied to an illegal element type.");
			}
		}
	}

	return methods;
}
 
开发者ID:MatthewTamlin,项目名称:Spyglass,代码行数:17,代码来源:MainProcessor.java

示例4: getKind

@DefinedBy(Api.LANGUAGE_MODEL)
public ElementKind getKind() {
    long flags = flags();
    if ((flags & PARAMETER) != 0) {
        if (isExceptionParameter())
            return ElementKind.EXCEPTION_PARAMETER;
        else
            return ElementKind.PARAMETER;
    } else if ((flags & ENUM) != 0) {
        return ElementKind.ENUM_CONSTANT;
    } else if (owner.kind == TYP || owner.kind == ERR) {
        return ElementKind.FIELD;
    } else if (isResourceVariable()) {
        return ElementKind.RESOURCE_VARIABLE;
    } else {
        return ElementKind.LOCAL_VARIABLE;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:Symbol.java

示例5: getPanel

@Override
public CustomRefactoringPanel getPanel(ChangeListener parent) {
    if (panel == null) {
        String suffix = "";
        if(handle != null && handle.getKind() == Tree.Kind.LABELED_STATEMENT) {
            suffix = getString("LBL_Label");
        } else if (handle != null && handle.getElementHandle() !=null) {
            ElementKind kind = handle.getElementHandle().getKind();
            if (kind!=null && (kind.isClass() || kind.isInterface())) {
                suffix  = kind.isInterface() ? getString("LBL_Interface") : getString("LBL_Class");
            } else if (kind == ElementKind.METHOD) {
                suffix = getString("LBL_Method");
            } else if (kind == ElementKind.FIELD) {
                suffix = getString("LBL_Field");
            } else if (kind == ElementKind.LOCAL_VARIABLE) {
                suffix = getString("LBL_LocalVar");
            } else if (kind == ElementKind.PACKAGE || (handle == null && fromListener)) {
                suffix = pkgRename ? getString("LBL_Package") : getString("LBL_Folder");
            } else if (kind == ElementKind.PARAMETER) {
                suffix = getString("LBL_Parameter");
            }
        }
        suffix = suffix + " " + this.oldName; // NOI18N
        panel = new RenamePanel(handle, newName, parent, NbBundle.getMessage(RenamePanel.class, "LBL_Rename") + " " + suffix, !fromListener, fromListener && !byPassPakageRename);
    }
    return panel;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:RenameRefactoringUI.java

示例6: visitText

@Override
public DocTree visitText(TextTree node, Element p) {
    if(searchComment) {
        DocTrees trees = info.getDocTrees();
        DocSourcePositions sourcePositions = trees.getSourcePositions();
        DocTreePath currentDocPath = getCurrentPath();
        if(toFind.getKind() == ElementKind.PARAMETER) {
            VariableElement var = (VariableElement) toFind;
            Element method = trees.getElement(currentDocPath);
            if(!var.getEnclosingElement().equals(method)) {
                return super.visitText(node, p);
            }
        }
        String text = node.getBody();
        String name = toFind.getSimpleName().toString();
        if(text.contains(name)) {
            int start = (int) sourcePositions.getStartPosition(info.getCompilationUnit(), currentDocPath.getDocComment(), node);
            int length = name.length();
            int offset = -1;
            do {
                offset = text.indexOf(name, ++offset);
                if(offset != -1) {
                    try {
                        MutablePositionRegion region = createRegion(doc, start + offset, start + offset + length);
                        comments.add(region);
                    } catch(BadLocationException ex) {
                        Exceptions.printStackTrace(ex);
                    }
                }
            } while (offset != -1);
        }
    }
    return super.visitText(node, p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:FindLocalUsagesQuery.java

示例7: isLocalVariable

private boolean isLocalVariable(IdentifierTree id, Trees trees) {
    Element el = trees.getElement(TreePath.getPath(treePath, id));
    if (el != null) {
        return el.getKind() == ElementKind.LOCAL_VARIABLE || el.getKind() == ElementKind.PARAMETER;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:PreconditionsChecker.java

示例8: visitIdentifier

@Override
public Object visitIdentifier(IdentifierTree node, Object p) {
    Element el = ci.getTrees().getElement(getCurrentPath());
    if (el != null && el.getKind() == ElementKind.PARAMETER) {
        unusedVars.remove(el);
        if (unusedVars.isEmpty()) {
            throw new StopProcessing();
        }
    }
    return super.visitIdentifier(node, p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ComparatorParameterNotUsed.java

示例9: assignmentToMethodParam

@Hint(displayName = "#DN_org.netbeans.modules.java.hints.AssignmentIssues.assignmentToMethodParam", description = "#DESC_org.netbeans.modules.java.hints.AssignmentIssues.assignmentToMethodParam", category = "assignment_issues", enabled = false, suppressWarnings = "AssignmentToMethodParameter", options=Options.QUERY) //NOI18N
@TriggerTreeKind({Kind.ASSIGNMENT, Kind.AND_ASSIGNMENT, Kind.DIVIDE_ASSIGNMENT,
    Kind.LEFT_SHIFT_ASSIGNMENT, Kind.MINUS_ASSIGNMENT, Kind.MULTIPLY_ASSIGNMENT,
    Kind.OR_ASSIGNMENT, Kind.PLUS_ASSIGNMENT, Kind.REMAINDER_ASSIGNMENT, Kind.RIGHT_SHIFT_ASSIGNMENT,
    Kind.UNSIGNED_RIGHT_SHIFT_ASSIGNMENT, Kind.XOR_ASSIGNMENT, Kind.PREFIX_INCREMENT,
    Kind.PREFIX_DECREMENT, Kind.POSTFIX_INCREMENT, Kind.POSTFIX_DECREMENT})
public static ErrorDescription assignmentToMethodParam(HintContext context) {
    final TreePath path = context.getPath();
    Element element = null;
    switch (path.getLeaf().getKind()) {
        case ASSIGNMENT:
            element = context.getInfo().getTrees().getElement(TreePath.getPath(path, ((AssignmentTree) path.getLeaf()).getVariable()));
            break;
        case PREFIX_INCREMENT:
        case PREFIX_DECREMENT:
        case POSTFIX_INCREMENT:
        case POSTFIX_DECREMENT:
            element = context.getInfo().getTrees().getElement(TreePath.getPath(path, ((UnaryTree) path.getLeaf()).getExpression()));
            break;
        default:
            element = context.getInfo().getTrees().getElement(TreePath.getPath(path, ((CompoundAssignmentTree) path.getLeaf()).getVariable()));
    }
    if (element != null && element.getKind() == ElementKind.PARAMETER) {
        return ErrorDescriptionFactory.forTree(context, path, NbBundle.getMessage(AssignmentIssues.class, "MSG_AssignmentToMethodParam", element.getSimpleName())); //NOI18N
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:AssignmentIssues.java

示例10: visitVariable

@Override
public Void visitVariable(VariableElement e, Boolean highlightName) {
    modifier(e.getModifiers());
    
    result.append(getTypeName(info, e.asType(), true));
    
    result.append(' ');
    
    boldStartCheck(highlightName);

    result.append(e.getSimpleName());
    
    boldStopCheck(highlightName);
    
    if (highlightName) {
        if (e.getConstantValue() != null) {
            result.append(" = ");
            result.append(StringEscapeUtils.escapeHtml(e.getConstantValue().toString()));
        }
        
        Element enclosing = e.getEnclosingElement();
        
        if (e.getKind() != ElementKind.PARAMETER && e.getKind() != ElementKind.LOCAL_VARIABLE
                && e.getKind() != ElementKind.RESOURCE_VARIABLE && e.getKind() != ElementKind.EXCEPTION_PARAMETER) {
            result.append(" in ");

            //short typename:
            result.append(getTypeName(info, enclosing.asType(), true));
        }
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:GoToSupport.java

示例11: isLocalVariableClosure

private static boolean isLocalVariableClosure(Element el) {
    return el.getKind() == ElementKind.PARAMETER || el.getKind() == ElementKind.LOCAL_VARIABLE
            || el.getKind() == ElementKind.RESOURCE_VARIABLE || el.getKind() == ElementKind.EXCEPTION_PARAMETER;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:SemanticHighlighterBase.java


注:本文中的javax.lang.model.element.ElementKind.PARAMETER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。