public boolean visit(VariableDeclarationFragment node) { SimpleName name = node.getName(); System.out.println("Declaration of '"+name+"' at line"+cu.getLineNumber(name.getStartPosition())); int modifiers = 0; if (node.getParent() instanceof FieldDeclaration){ modifiers = ((FieldDeclaration)node.getParent()).getModifiers(); } else if (node.getParent() instanceof VariableDeclarationStatement){ modifiers = ((VariableDeclarationStatement)node.getParent()).getModifiers(); } return false; }
public boolean visit(VariableDeclarationFragment f) { if (f.getParent() instanceof FieldDeclaration) { FieldDeclaration d = (FieldDeclaration) f.getParent(); if (d.getType().isParameterizedType()) { ParameterizedType parType = (ParameterizedType) d.getType(); System.out.println("Par type : " + parType.typeArguments().get(0).toString()); } } }
public boolean visit(VariableDeclarationFragment node) { if(!(node.getParent() instanceof LambdaExpression)) variableDeclarations.add(new VariableDeclaration(cu, filePath, node)); return super.visit(node); }
@Override public boolean visit(VariableDeclarationFragment node) { if (name.equals(node.getName().getFullyQualifiedName())) { result[0]= node.getParent(); throw new STOP_VISITING(); } return true; } });
@Override public boolean visit(VariableDeclarationFragment node) { if (name.equals(node.getName().getFullyQualifiedName())) { result[0]= node.getParent(); throw new STOP_VISITING(); } return true; } });
private String getFieldName(VariableDeclarationFragment node) { StringBuffer buffer= new StringBuffer(); buffer.append(node.getName().toString()); ASTNode parent= node.getParent(); if (parent instanceof FieldDeclaration) { FieldDeclaration fd= (FieldDeclaration) parent; buffer.append(" : "); //$NON-NLS-1$ buffer.append(getType(fd.getType())); } return buffer.toString(); }
private String getFieldName(VariableDeclarationFragment node) { StringBuilder buffer= new StringBuilder(); buffer.append(node.getName().toString()); ASTNode parent= node.getParent(); if (parent instanceof FieldDeclaration) { FieldDeclaration fd= (FieldDeclaration) parent; buffer.append(" : "); //$NON-NLS-1$ buffer.append(getType(fd.getType())); } return buffer.toString(); }
private String getFieldName(VariableDeclarationFragment node) { StringBuffer buffer= new StringBuffer(); buffer.append(node.getName().toString()); ASTNode parent= node.getParent(); if (parent instanceof FieldDeclaration) { FieldDeclaration fd= (FieldDeclaration) parent; buffer.append(" : "); //$NON-NLS-1$ buffer.append(getType(fd.getType())); } return buffer.toString(); }
unitNode.accept(new ASTVisitor() { @Override public boolean visit(VariableDeclarationFragment node) { IJavaElement element = node.resolveBinding().getJavaElement(); if (field.equals(element)) { FieldDeclaration fieldDeclaration = (FieldDeclaration)node.getParent(); IType fieldType = (IType)fieldDeclaration.getType().resolveBinding().getJavaElement(); } return false; } });
public boolean visit(VariableDeclarationFragment node) { if (name.equals(node.getName().getFullyQualifiedName())) { result[0]= node.getParent(); throw new STOP_VISITING(); } return true; } });
private void addField(Field<Body> field) { final List<BodyDeclaration> bodyDeclarations = getBody().bodyDeclarations(); int idx = 0; for (BodyDeclaration bodyDeclaration : bodyDeclarations) { if (!(bodyDeclaration instanceof FieldDeclaration)) { break; } idx++; } bodyDeclarations.add(idx, (BodyDeclaration) ((VariableDeclarationFragment) field.getInternal()).getParent()); }
public static org.eclipse.jdt.core.dom.Type fromString(String resolvedType, AST ast) { String stub = "public class Stub { " + resolvedType + " field; }"; JavaClassSource temp = (JavaClassSource) Roaster.parse(stub); List<FieldSource<JavaClassSource>> fields = temp.getFields(); org.eclipse.jdt.core.dom.Type fieldType = ((FieldDeclaration) ((VariableDeclarationFragment) fields.get(0) .getInternal()).getParent()).getType(); return (org.eclipse.jdt.core.dom.Type) ASTNode.copySubtree(ast, fieldType); } }
@Override public boolean visit(VariableDeclarationFragment node) { if (node.getParent() instanceof FieldDeclaration || node.getInitializer() != null) addWrite(node.getName(), node.resolveBinding()); return true; }
@Override public boolean visit(VariableDeclarationFragment node) { String name= getFieldName(node); ASTNode parent= node.getParent(); push(JavaNode.FIELD, name, parent.getStartPosition(), parent.getLength()); return false; }
public boolean visit(VariableDeclarationFragment node) { String name= getFieldName(node); ASTNode parent= node.getParent(); push(JavaNode.FIELD, name, parent.getStartPosition(), parent.getLength()); return false; }
@Override public boolean visit(VariableDeclarationFragment node) { if (node.getParent() instanceof FieldDeclaration || node.getInitializer() != null) addWrite(node.getName(), node.resolveBinding()); return true; }
@Override public boolean visit(VariableDeclarationFragment node) { String name= getFieldName(node); ASTNode parent= node.getParent(); push(JavaNode.FIELD, name, parent.getStartPosition(), parent.getLength()); return false; }
@Override public boolean visit(VariableDeclarationFragment node) { boolean result = super.visit(node); if (isFirstSelectedNode(node)) { if (node.getParent() instanceof FieldDeclaration) { invalidSelection(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_variable_declaration_fragment_from_field, JavaStatusContext.create(fCUnit, node)); } else { invalidSelection(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_variable_declaration_fragment, JavaStatusContext.create(fCUnit, node)); } return false; } return result; }
public boolean visit(VariableDeclarationFragment node) { if (node.getParent().getNodeType() == ASTNode.FIELD_DECLARATION || node.getInitializer() != null) match(node.getName(), fWriteUsages, node.resolveBinding()); return super.visit(node); }
@Override public boolean visit(VariableDeclarationFragment node) { boolean result= super.visit(node); if (isFirstSelectedNode(node)) { if (node.getParent() instanceof FieldDeclaration) { invalidSelection(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_variable_declaration_fragment_from_field, JavaStatusContext.create(fCUnit, node)); } else { invalidSelection(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_variable_declaration_fragment, JavaStatusContext.create(fCUnit, node)); } return false; } return result; }