本文整理汇总了Java中com.github.javaparser.ast.expr.VariableDeclarationExpr.getVariables方法的典型用法代码示例。如果您正苦于以下问题:Java VariableDeclarationExpr.getVariables方法的具体用法?Java VariableDeclarationExpr.getVariables怎么用?Java VariableDeclarationExpr.getVariables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ast.expr.VariableDeclarationExpr
的用法示例。
在下文中一共展示了VariableDeclarationExpr.getVariables方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: solveSymbolAsValue
import com.github.javaparser.ast.expr.VariableDeclarationExpr; //导入方法依赖的package包/类
@Override
public Optional<Value> solveSymbolAsValue(String name, TypeSolver typeSolver) {
for (VariableDeclarationExpr expr : wrappedNode.getResources()) {
for (VariableDeclarator v : expr.getVariables()) {
if (v.getName().getIdentifier().equals(name)) {
JavaParserSymbolDeclaration decl = JavaParserSymbolDeclaration.localVar(v, typeSolver);
return Optional.of(Value.from(decl));
}
}
}
if (getParentNode(wrappedNode) instanceof BlockStmt) {
return StatementContext.solveInBlockAsValue(name, typeSolver, wrappedNode);
} else {
return getParent().solveSymbolAsValue(name, typeSolver);
}
}
示例2: solveSymbol
import com.github.javaparser.ast.expr.VariableDeclarationExpr; //导入方法依赖的package包/类
@Override
public SymbolReference<? extends ValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) {
for (VariableDeclarationExpr expr : wrappedNode.getResources()) {
for (VariableDeclarator v : expr.getVariables()) {
if (v.getName().getIdentifier().equals(name)) {
return SymbolReference.solved(JavaParserSymbolDeclaration.localVar(v, typeSolver));
}
}
}
if (getParentNode(wrappedNode) instanceof BlockStmt) {
return StatementContext.solveInBlock(name, typeSolver, wrappedNode);
} else {
return getParent().solveSymbol(name, typeSolver);
}
}
示例3: solveSymbol
import com.github.javaparser.ast.expr.VariableDeclarationExpr; //导入方法依赖的package包/类
@Override
public SymbolReference<? extends ValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) {
for (Expression expression : wrappedNode.getInitialization()) {
if (expression instanceof VariableDeclarationExpr) {
VariableDeclarationExpr variableDeclarationExpr = (VariableDeclarationExpr) expression;
for (VariableDeclarator variableDeclarator : variableDeclarationExpr.getVariables()) {
if (variableDeclarator.getName().getId().equals(name)) {
return SymbolReference.solved(JavaParserSymbolDeclaration.localVar(variableDeclarator, typeSolver));
}
}
} else if (!(expression instanceof AssignExpr || expression instanceof MethodCallExpr)) {
throw new UnsupportedOperationException(expression.getClass().getCanonicalName());
}
}
if (getParentNode(wrappedNode) instanceof NodeWithStatements) {
return StatementContext.solveInBlock(name, typeSolver, wrappedNode);
} else {
return getParent().solveSymbol(name, typeSolver);
}
}
示例4: solveSymbol
import com.github.javaparser.ast.expr.VariableDeclarationExpr; //导入方法依赖的package包/类
@Override
public SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) {
for (Expression expression : wrappedNode.getInitialization()) {
if (expression instanceof VariableDeclarationExpr) {
VariableDeclarationExpr variableDeclarationExpr = (VariableDeclarationExpr) expression;
for (VariableDeclarator variableDeclarator : variableDeclarationExpr.getVariables()) {
if (variableDeclarator.getName().getId().equals(name)) {
return SymbolReference.solved(JavaParserSymbolDeclaration.localVar(variableDeclarator, typeSolver));
}
}
} else if (!(expression instanceof AssignExpr || expression instanceof MethodCallExpr)) {
throw new UnsupportedOperationException(expression.getClass().getCanonicalName());
}
}
if (getParentNode(wrappedNode) instanceof NodeWithStatements) {
return StatementContext.solveInBlock(name, typeSolver, wrappedNode);
} else {
return getParent().solveSymbol(name, typeSolver);
}
}
示例5: visit
import com.github.javaparser.ast.expr.VariableDeclarationExpr; //导入方法依赖的package包/类
@Override
public final void visit(VariableDeclarationExpr ctx, Object arg) {
final Component cmp = createComponent(ctx, OOPSourceModelConstants.ComponentType.LOCAL);
for (final AnnotationExpr annot : ctx.getAnnotations()) {
populateAnnotation(cmp, annot);
}
cmp.setAccessModifiers(resolveJavaParserModifiers(ctx.getModifiers()));
final List<Component> vars = new ArrayList<Component>();
for (final VariableDeclarator copy : ctx.getVariables()) {
final Component tmp = new Component(cmp);
tmp.setName(copy.getNameAsString());
tmp.setComponentName(generateComponentName(copy.getNameAsString()));
pointParentsToGivenChild(tmp);
vars.add(tmp);
}
for (final Component tmpCmp : vars) {
componentStack.push(tmpCmp);
}
super.visit(ctx, arg);
int numVars = ctx.getVariables().size();
for (int i = 0; i < numVars; i++) {
completeComponent();
}
}
示例6: visit
import com.github.javaparser.ast.expr.VariableDeclarationExpr; //导入方法依赖的package包/类
@Override public void visit(final VariableDeclarationExpr n, final A arg) {
visitComment(n.getComment(), arg);
visitAnnotations(n, arg);
n.getElementType().accept(this, arg);
for (final VariableDeclarator v : n.getVariables()) {
v.accept(this, arg);
}
}
示例7: visit
import com.github.javaparser.ast.expr.VariableDeclarationExpr; //导入方法依赖的package包/类
@Override public Node visit(final VariableDeclarationExpr n, final A arg) {
visitComment(n, arg);
final List<AnnotationExpr> annotations = n.getAnnotations();
if (annotations != null) {
for (int i = 0; i < annotations.size(); i++) {
annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg));
}
removeNulls(annotations);
}
final Type type = (Type) n.getElementType().accept(this, arg);
if (type == null) {
return null;
}
n.setElementType(type);
final List<VariableDeclarator> vars = n.getVariables();
for (int i = 0; i < vars.size();) {
final VariableDeclarator decl = (VariableDeclarator)
vars.get(i).accept(this, arg);
if (decl == null) {
vars.remove(i);
} else {
vars.set(i++, decl);
}
}
if (vars.isEmpty()) {
return null;
}
return n;
}
示例8: visit
import com.github.javaparser.ast.expr.VariableDeclarationExpr; //导入方法依赖的package包/类
/**
* Check if class variables is in camelCase, not in underscore_case,
* since in Java we use camelCase naming convention
*
* @param declaration
* @param collector
*/
@Override
public void visit(VariableDeclarationExpr declaration, Collector collector) {
if (Config.PARAM_IN_CAMEL_CASE) {
for (VariableDeclarator variable: declaration.getVariables()) {
String name = variable.getNameAsString();
if (name.matches(OK_REGEX)) // e.x. SOME_VARIABLE is OKAY
continue;
if (name.contains("_")) {
collector.addWarning(className, "Method \"" + methodName + "\" variable \"" + name +"\" should be in 'camelCase', not in 'underscore_case'");
}
}
}
}
示例9: visit
import com.github.javaparser.ast.expr.VariableDeclarationExpr; //导入方法依赖的package包/类
/**
* Check for too many variables & for too long ones
*
* @param declaration
* @param collector
*/
@Override
public void visit(VariableDeclarationExpr declaration, Collector collector) {
if (declaration.getVariables().size() > MAX_VARIABLE_COUNT) {
collector.addWarning(className, "Class has more than " + MAX_VARIABLE_COUNT + " variables");
}
for (VariableDeclarator variable: declaration.getVariables()) {
if (variable.getNameAsString().length() > MAX_VARIABLE_LENGTH) {
collector.addWarning(className, "Field variable \"" + variable.getNameAsString() +"\" is way too long!");
}
}
}
示例10: visit
import com.github.javaparser.ast.expr.VariableDeclarationExpr; //导入方法依赖的package包/类
/**
* Check for too short variable names
*
* @param declaration
* @param collector
*/
@Override
public void visit(VariableDeclarationExpr declaration, Collector collector) {
for (VariableDeclarator variable: declaration.getVariables()) {
if (variable.getNameAsString().length() < MIN_VARIABLE_LENGTH) {
collector.addWarning(className, "Variable \"" + variable.getNameAsString() + "\" length is too small");
}
}
}