List of usage examples for org.eclipse.jdt.core.dom SingleVariableDeclaration NAME_PROPERTY
ChildPropertyDescriptor NAME_PROPERTY
To view the source code for org.eclipse.jdt.core.dom SingleVariableDeclaration NAME_PROPERTY.
Click Source Link
From source file:org.autorefactor.refactoring.rules.VariableDefinitionsUsesVisitor.java
License:Open Source License
@Override public boolean visit(SimpleName node) { if (isSameLocalVariable(variableBinding, node)) { switch (node.getParent().getNodeType()) { case ASSIGNMENT: addDefinitionOrUse(node, Assignment.LEFT_HAND_SIDE_PROPERTY); break; case VARIABLE_DECLARATION_FRAGMENT: addDefinitionOrUse(node, VariableDeclarationFragment.NAME_PROPERTY); break; case SINGLE_VARIABLE_DECLARATION: addDefinitionOrUse(node, SingleVariableDeclaration.NAME_PROPERTY); break; default:/*from ww w.j a v a 2s. c o m*/ uses.add(node); break; } } return VISIT_SUBTREE; }
From source file:org.eclipse.emf.codegen.merge.java.facade.ast.ASTJMethod.java
License:Open Source License
/** * Sets parameter names. New parameter names will not be returned by {@link #getParameters()}, * but will be returned by {@link #getParameterNames()}. * //from w w w.j a v a2 s . c om * @see #getParameterNames() * @see #getParameters() * @see org.eclipse.emf.codegen.merge.java.facade.JMethod#setParameterNames(java.lang.String[]) */ public void setParameterNames(String[] names) { @SuppressWarnings("unchecked") List<SingleVariableDeclaration> parameters = getASTNode().parameters(); if (parameters.size() != names.length) { throw new IllegalArgumentException("Length of names must match number of existing parameters."); } this.parameterNames = names; int i = 0; for (SingleVariableDeclaration parameter : parameters) { setNodeProperty(parameter, names[i++], SingleVariableDeclaration.NAME_PROPERTY, ASTNode.SIMPLE_NAME); } }
From source file:org.eclipse.recommenders.jdt.templates.SnippetCodeBuilder.java
License:Open Source License
private boolean isDeclaration(SimpleName name) { if (VariableDeclarationFragment.NAME_PROPERTY.equals(name.getLocationInParent())) { return true; } else if (SingleVariableDeclaration.NAME_PROPERTY.equals(name.getLocationInParent())) { return true; } else {// w ww .j ava 2s. co m return false; } }
From source file:org.eclipse.wb.internal.core.eval.evaluators.SimpleNameEvaluator.java
License:Open Source License
private Object evaluateAsAssignment(EvaluationContext context, SimpleName simpleName) throws Exception { ExpressionValue value = ExecutionFlowUtils2.getValue(context.getFlowDescription(), simpleName); if (value != null) { Expression expression = value.getExpression(); // field declaration without initializer if (expression.getLocationInParent() == VariableDeclarationFragment.NAME_PROPERTY && expression.getParent().getLocationInParent() == FieldDeclaration.FRAGMENTS_PROPERTY) { return null; }/*from ww w . j a v a 2s .com*/ // parameter of method without invocation if (expression.getLocationInParent() == SingleVariableDeclaration.NAME_PROPERTY) { SingleVariableDeclaration parameter = (SingleVariableDeclaration) expression.getParent(); MethodDeclaration methodDeclaration = AstNodeUtils.getEnclosingMethod(parameter); return context.evaluateUnknownParameter(methodDeclaration, parameter); } // normal Expression return AstEvaluationEngine.evaluate(context, expression); } // no value throw new DesignerException(ICoreExceptionConstants.EVAL_NO_SIMPLE_NAME_FOUND, simpleName.getIdentifier()); }
From source file:org.moe.natjgen.MethodEditor.java
License:Apache License
@SuppressWarnings("unchecked") public void setArgument(int idx, String arg_name, Type type, TypeResolver resolver) throws GeneratorException { editLock();// www.j a v a 2s . c om ListRewrite mlrw = getRewrite().getListRewrite(methodDecl, MethodDeclaration.PARAMETERS_PROPERTY); List<SingleVariableDeclaration> list = (List<SingleVariableDeclaration>) mlrw.getRewrittenList(); SingleVariableDeclaration svd = list.get(idx); SimpleName property = (SimpleName) getRewrite().get(svd, SingleVariableDeclaration.NAME_PROPERTY); if (property == null || !property.getFullyQualifiedName().equals(arg_name)) { getRewrite().set(svd, SingleVariableDeclaration.NAME_PROPERTY, getAST().newName(arg_name), getEditGroup()); } ModifierEditor argmod = new ModifierEditor(getManager(), svd, SingleVariableDeclaration.MODIFIERS2_PROPERTY, true); resolver.resolve(getManager(), svd, SingleVariableDeclaration.TYPE_PROPERTY, argmod, type, true); argmod.close(); // Add uncertain descriptor UncertainDescriptor udesc = argmod.getUncertainDescriptor(); if (udesc != null) { uncertains.add(new UncertainElem(Integer.toString(idx), udesc)); } }
From source file:org.moe.natjgen.MethodEditor.java
License:Apache License
@SuppressWarnings("unchecked") public void setVariadicArgument(int idx, String arg_name) throws GeneratorException { editLock();/*w ww . j a v a 2s . c o m*/ ListRewrite mlrw = getRewrite().getListRewrite(methodDecl, MethodDeclaration.PARAMETERS_PROPERTY); List<SingleVariableDeclaration> list = (List<SingleVariableDeclaration>) mlrw.getRewrittenList(); SingleVariableDeclaration svd = list.get(idx); SimpleName property = (SimpleName) getRewrite().get(svd, SingleVariableDeclaration.NAME_PROPERTY); if (property == null || !property.getFullyQualifiedName().equals(arg_name)) { getRewrite().set(svd, SingleVariableDeclaration.NAME_PROPERTY, getAST().newName(arg_name), getEditGroup()); } SimpleType type = getAST().newSimpleType(getAST().newName("Object")); getRewrite().set(svd, SingleVariableDeclaration.TYPE_PROPERTY, type, getEditGroup()); getRewrite().set(svd, SingleVariableDeclaration.VARARGS_PROPERTY, Boolean.TRUE, getEditGroup()); }