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()); } } }
@Override public ITypeConstraint[] create(FieldDeclaration fd){ List<ITypeConstraint> result= new ArrayList<>(); result.addAll(Arrays.asList(getConstraintsFromFragmentList(fd.fragments(), fd.getType()))); result.addAll(getConstraintsForHiding(fd)); result.addAll(getConstraintsForFieldDeclaringTypes(fd)); return result.toArray(new ITypeConstraint[result.size()]); }
@Override public ITypeConstraint[] create(FieldDeclaration fd){ List<ITypeConstraint> result= new ArrayList<>(); result.addAll(Arrays.asList(getConstraintsFromFragmentList(fd.fragments(), fd.getType()))); result.addAll(getConstraintsForHiding(fd)); result.addAll(getConstraintsForFieldDeclaringTypes(fd)); return result.toArray(new ITypeConstraint[result.size()]); }
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(); }
@Override public void endVisit(FieldDeclaration node) { // TODO: in principle, no need to tie the VariableDeclarationFragments together. // The FieldDeclaration can be split up when fragments get different types. // Warning: still need to connect fragments with type! endVisitFieldVariableDeclaration(node.getType(), node.fragments()); }
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 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 void endVisit(FieldDeclaration node) { if (skipNode(node)) { return; } GenericSequentialFlowInfo info = processSequential(node, node.getType()); process(info, node.fragments()); }
@Override public void endVisit(FieldDeclaration node) { if (skipNode(node)) return; GenericSequentialFlowInfo info= processSequential(node, node.getType()); process(info, node.fragments()); }
public boolean visit(FieldDeclaration node) { IValueList extendedModifiers = parseExtendedModifiers(node); IValue type = visitChild(node.getType()); IValueList fragments = new IValueList(values); for (Iterator it = node.fragments().iterator(); it.hasNext();) { VariableDeclarationFragment f = (VariableDeclarationFragment) it.next(); fragments.add(visitChild(f)); } ownValue = constructDeclarationNode("field", type, fragments.asList()); setKeywordParameters("modifiers", extendedModifiers); return false; }
@Override public void endVisit(FieldDeclaration node) { if (skipNode(node)) return; GenericSequentialFlowInfo info= processSequential(node, node.getType()); process(info, node.fragments()); }
public void endVisit(FieldDeclaration node) { // TODO: in principle, no need to tie the VariableDeclarationFragments together. // The FieldDeclaration can be split up when fragments get different types. // Warning: still need to connect fragments with type! endVisitFieldVariableDeclaration(node.getType(), node.fragments()); }
int treeSize() { return memSize() + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) + (this.modifiers == null ? 0 : this.modifiers.listSize()) + (this.baseType == null ? 0 : getType().treeSize()) + this.variableDeclarationFragments.listSize(); } }
int treeSize() { return memSize() + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) + (this.modifiers == null ? 0 : this.modifiers.listSize()) + (this.baseType == null ? 0 : getType().treeSize()) + this.variableDeclarationFragments.listSize(); } }
int treeSize() { return memSize() + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) + (this.modifiers == null ? 0 : this.modifiers.listSize()) + (this.baseType == null ? 0 : getType().treeSize()) + this.variableDeclarationFragments.listSize(); } }
@Override int treeSize() { return memSize() + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) + (this.modifiers == null ? 0 : this.modifiers.listSize()) + (this.baseType == null ? 0 : getType().treeSize()) + this.variableDeclarationFragments.listSize(); } }
int treeSize() { return memSize() + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) + (this.modifiers == null ? 0 : this.modifiers.listSize()) + (this.baseType == null ? 0 : getType().treeSize()) + this.variableDeclarationFragments.listSize(); } }
private Attribute ensureAttributeFromFragmentIntoParentType(VariableDeclarationFragment fragment, FieldDeclaration field, Type parentType) { String name = fragment.getName().toString(); String qualifiedName = Famix.qualifiedNameOf(parentType) + "." + name; if (attributes.has(qualifiedName)) return attributes.named(qualifiedName); Attribute attribute = ensureBasicAttribute(parentType, name, qualifiedName, ensureTypeFromDomType(field.getType())); return attribute; }
private boolean isConstField(FieldDeclaration node, VariableDeclarationFragment fragment) { // if (fragment.resolveBinding().getDeclaringClass().isInterface()) return true; return Modifier.isFinal(node.getModifiers()) && isSupportedConstantType(node.getType()) && hasConstValue(fragment) && Modifier.isStatic(node.getModifiers()); }