List of usage examples for org.eclipse.jdt.core.dom Initializer toString
@Override public final String toString()
From source file:fr.labri.harmony.rta.junit.jdt.JDTVisitorRTA.java
License:Open Source License
public boolean visit(Initializer b) { superInvocation = false;//from w ww.j av a2s . co m if (currentClass == null) { return false; } // Test required in case of default constructors that have null bindings if (b != null) { String id = currentClass.getQualifiedName() + ".Block$" + cptStaticBlock; currentJavaMethod = getJavaMethod(id); currentJavaMethod.setQualifiedName(id); currentJavaMethod.setShortSignature("Block$" + cptStaticBlock); cptStaticBlock++; currentJavaMethod.setIntern(true); currentJavaMethod.setConstructor(false); currentJavaMethod.setStaticBlock(true); currentJavaMethod.setClassName(currentClass); currentJavaMethod.getDirectCalls().clear(); currentJavaMethod.getCallsSite().clear(); currentJavaMethod.getInstantiatedClass().clear(); if (b.getBody() == null) hashes.put(id, MD5Generator.md5(b.toString().trim())); else hashes.put(id, MD5Generator.md5(b.getBody().toString().trim())); // // IMethodBinding mim = Bindings.findOverriddenMethod(b, true); // if(mim!=null) // addAction(getMethodBindingId(mim),id); } else return false; return true; }
From source file:lang.java.jdt.internal.BindingConverter.java
License:Open Source License
private IList importInitializer(Initializer init, ITypeBinding possibleParent) { IListWriter lw = VF.listWriter(ADT_ID); lw.append(VF.constructor(CONS_INITIALIZER_NUMBERED, VF.integer(initializerCounter++))); IList l = lw.done();/*from w ww .j a v a 2 s.c o m*/ if (possibleParent != null) { IList parentName = getIds(possibleParent); l = parentName.concat(l); } else { System.err.println("dangling initializer " + init.toString()); } return l; }
From source file:lang.java.jdt.internal.JDTImporter.java
License:Open Source License
private void importTypeInfo(ASTNode n) { ITypeBinding tb = null;//from w w w .j a v a2s .c om if (n instanceof TypeDeclaration) { tb = ((TypeDeclaration) n).resolveBinding(); } if (n instanceof TypeDeclarationStatement) { tb = ((TypeDeclarationStatement) n).getDeclaration().resolveBinding(); } if (n instanceof AnonymousClassDeclaration) { tb = ((AnonymousClassDeclaration) n).resolveBinding(); } if (n instanceof EnumDeclaration) { tb = ((EnumDeclaration) n).resolveBinding(); } if (tb != null) { importTypeInfo(tb); if (tb.isClass()) addBinding(classBindings, n, bindingCache.getEntity(tb)); else if (tb.isInterface()) addBinding(interfaceBindings, n, bindingCache.getEntity(tb)); else if (tb.isEnum()) addBinding(enumBindings, n, bindingCache.getEntity(tb)); } // EnumDeclaration // EnumConstantDeclaration // FieldDeclaration // MethodDeclaration // Initializer if (n instanceof Initializer) { Initializer init = (Initializer) n; ITypeBinding parentType = typeStack.peek(); if (parentType != null) { ITuple tup = VF.tuple(bindingCache.getEntity(parentType), bindingCache.getEntity(init, parentType)); declaredMethods.insert(tup); } else { System.err.println("dangling initializer " + init.toString()); } } if (n instanceof BodyDeclaration) { List<IValue> owners = new ArrayList<IValue>(); if (n instanceof AbstractTypeDeclaration) { owners.add(bindingCache.getEntity(((AbstractTypeDeclaration) n).resolveBinding())); } else if (n instanceof AnnotationTypeMemberDeclaration) { owners.add(bindingCache.getEntity(((AnnotationTypeMemberDeclaration) n).resolveBinding())); } else if (n instanceof Initializer) { owners.add(bindingCache.getEntity((Initializer) n)); } else if (n instanceof MethodDeclaration) { owners.add(bindingCache.getEntity(((MethodDeclaration) n).resolveBinding())); } else if (n instanceof FieldDeclaration) { for (Object fragment : ((FieldDeclaration) n).fragments()) { owners.add(bindingCache.getEntity(((VariableDeclarationFragment) fragment).resolveBinding())); } } else if (n instanceof EnumConstantDeclaration) { owners.add(bindingCache.getEntity(((EnumConstantDeclaration) n).resolveConstructorBinding())); owners.add(bindingCache.getEntity(((EnumConstantDeclaration) n).resolveVariable())); } BodyDeclaration bd = (BodyDeclaration) n; List<IValue> modsForN = bindingCache.getModifiers(bd.modifiers()); Javadoc doc = bd.getJavadoc(); if (doc != null) { for (Object te : doc.tags()) { if (TagElement.TAG_DEPRECATED.equals(((TagElement) te).getTagName())) { modsForN.add(BindingConverter.deprecatedModifier); break; } } } for (IValue owner : owners) { for (IValue modifier : modsForN) { modifiers.insert(VF.tuple(owner, modifier)); } } } // method -> parameters? // method -> local variables? // throws? // modifiers? // scopes? not in JDT :( }