List of usage examples for org.eclipse.jdt.internal.compiler.ast ASTNode print
public abstract StringBuffer print(int indent, StringBuffer output);
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.MatchingNodeSet.java
License:Open Source License
public String toString() { // TODO (jerome) should show both tables StringBuffer result = new StringBuffer(); result.append("Exact matches:"); //$NON-NLS-1$ Object[] keyTable = this.matchingNodes.keyTable; Object[] valueTable = this.matchingNodes.valueTable; for (int i = 0, l = keyTable.length; i < l; i++) { ASTNode node = (ASTNode) keyTable[i]; if (node == null) continue; result.append("\n\t"); //$NON-NLS-1$ switch (((Integer) valueTable[i]).intValue()) { case SearchMatch.A_ACCURATE: result.append("ACCURATE_MATCH: "); //$NON-NLS-1$ break; case SearchMatch.A_INACCURATE: result.append("INACCURATE_MATCH: "); //$NON-NLS-1$ break; case SearchPattern.R_ERASURE_MATCH: result.append("ERASURE_MATCH: "); //$NON-NLS-1$ break; }//from ww w . j av a2 s.c om node.print(0, result); } result.append("\nPossible matches:"); //$NON-NLS-1$ Object[] nodes = this.possibleMatchingNodesSet.values; for (int i = 0, l = nodes.length; i < l; i++) { ASTNode node = (ASTNode) nodes[i]; if (node == null) continue; result.append("\nPOSSIBLE_MATCH: "); //$NON-NLS-1$ node.print(0, result); } return result.toString(); }
From source file:edu.tum.cs.conqat.inspection.sampling.RandomCodeSampleStrategy.java
License:Apache License
/** * Finds all identifiers by visiting the compiled javaClassElements by an * {@link IdentifierVisitor}./*from www.j a va 2 s .co m*/ */ private List<Sample> getIdentifierSamples(List<IJavaElement> javaClassElements) throws ConQATException { List<Sample> samples = new ArrayList<Sample>(); for (IJavaElement element : javaClassElements) { CompilationUnitDeclaration unitDeclaration = JavaLibrary.getEcjAST(element) .getCompilationUnitDeclaration(); ASTVisitor visitor = new IdentifierVisitor(); unitDeclaration.traverse(visitor, unitDeclaration.scope); unitDeclaration.cleanUp(); String sourcePath = element.getLocation(); for (ASTNode node : foundASTNodes) { StringBuffer buffer = new StringBuffer(); node.print(0, buffer); String name = buffer.toString(); Sample sample = CmFactory.eINSTANCE.createSample(); sample.setName(name); sample.setSourcePath(sourcePath); sample.setSourceStart(node.sourceStart); sample.setSourceEnd(node.sourceEnd + 1); sample.setPackagePath(element.getId()); samples.add(sample); } foundASTNodes.clear(); } return samples; }