@Override public double getMetricForASTNode(final ASTNode node) { return node.toString().split(System.getProperty("line.separator")).length; }
static String codeExcerpt(ASTNode node) { final String nodeString = node.toString(); final String[] nodeLines = nodeString.split("\n"); final String codeExcerpt; if (nodeLines[0].matches("\\s*\\{\\s*")) { codeExcerpt = nodeLines[0] + " " + nodeLines[1] + " ..."; } else { codeExcerpt = nodeLines[0]; } return codeExcerpt.replaceAll("\\s+", " "); } }
@Override protected boolean visitNode(ASTNode node) { Assert.isTrue(false, "No implementation to flatten node: " + node.toString()); //$NON-NLS-1$ return false; }
@Override protected boolean visitNode(ASTNode node) { Assert.isTrue(false, "No implementation to flatten node: " + node.toString()); //$NON-NLS-1$ return false; }
private String getNestedParentName() { final String regex = "public|private[ ]{1,}class[ ]{1,}([^\\{]*)[\\{]{1}"; final String inputString = this.fieldDeclaration.getParent().toString(); final Pattern pattern = Pattern.compile(regex); final Matcher matcher = pattern.matcher(inputString); String typeName = ""; while (matcher.find()) { typeName = matcher.group(1); return typeName; } return ""; }
protected boolean visitNode(ASTNode node) { Assert.isTrue(false, "No implementation to flatten node: " + node.toString()); //$NON-NLS-1$ return false; }
private void check(ASTNode node) { String ann = node.toString().toLowerCase(); if(ann.contains(ROUTE_ANNOTATION)) plusOne(); }
private void notImplemented(ASTNode node) { throw new IllegalArgumentException(sourceInformation(node) + ": " + node.toString()); }
public static Expression getExpression(ASTNode invocation) { switch(invocation.getNodeType()) { case ASTNode.METHOD_INVOCATION: return ((MethodInvocation)invocation).getExpression(); case ASTNode.SUPER_METHOD_INVOCATION: case ASTNode.CONSTRUCTOR_INVOCATION: return null; default: throw new IllegalArgumentException(invocation.toString()); } }
private boolean isLinkWithSimpleLabel(List<ASTNode> fragments, final ASTNode linkTarget) { if (fragments.size() != 2) return false; if (!JavadocUtility.isTextFragment(fragments, 1)) return false; final String link = linkTarget.toString(); final String label = JavadocUtility.textFragment(fragments, 1); return label.equals(link) || label.equals(unqualifiedName(link)); }
public static IMethodBinding resolveBinding(ASTNode invocation) { switch(invocation.getNodeType()) { case ASTNode.METHOD_INVOCATION: return ((MethodInvocation)invocation).resolveMethodBinding(); case ASTNode.SUPER_METHOD_INVOCATION: return ((SuperMethodInvocation)invocation).resolveMethodBinding(); case ASTNode.CONSTRUCTOR_INVOCATION: return ((ConstructorInvocation)invocation).resolveConstructorBinding(); default: throw new IllegalArgumentException(invocation.toString()); } }
public static List getArguments(ASTNode invocation) { switch(invocation.getNodeType()) { case ASTNode.METHOD_INVOCATION: return ((MethodInvocation)invocation).arguments(); case ASTNode.SUPER_METHOD_INVOCATION: return ((SuperMethodInvocation)invocation).arguments(); case ASTNode.CONSTRUCTOR_INVOCATION: return ((ConstructorInvocation)invocation).arguments(); default: throw new IllegalArgumentException(invocation.toString()); } }
public String getFormattedRenamedCode(final String originalScopeCode, final String from, final String to, final String wholeFile) { final String code = getRenamedCode(originalScopeCode, from, to, wholeFile); final JavaASTExtractor ex = new JavaASTExtractor(false); return ex.getASTNode(code, parseKindToUseOnOriginal).toString(); }
@Override public boolean visit(final MethodDeclaration node) { final Collection<ASTNode> ex = node.thrownExceptions(); for (final ASTNode n : ex) { addToMap(identifiers, n, n.toString()); } return super.visit(node); }
private CSDocNode mapTagElementFragment(CSMember member, ASTNode node, boolean escapeText) { switch (node.getNodeType()) { case ASTNode.TAG_ELEMENT: return mapTagElement(member, (TagElement) node); case ASTNode.TEXT_ELEMENT: return mapTextElement((TextElement) node, escapeText); } warning(node, "Documentation node not supported: " + node.getClass() + ": " + node); return new CSDocTextNode(node.toString()); }
private String mapCRefTarget(ASTNode node, IBinding binding) { if (null == binding) { my(Configuration.class).getWarningHandler().warning(node, "Unresolved cref target"); return node.toString(); } return documentationNameFor(binding); }
@Override public void updateNode() throws JavaModelException { int start= fNode.getStartPosition(); int length= fNode.getLength(); String msg= "Cannot update found node: nodeType=" + fNode.getNodeType() + "; " //$NON-NLS-1$//$NON-NLS-2$ + fNode.toString() + "[" + start + ", " + length + "] in " + fCuRewrite.getCu(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ JavaPlugin.log(new Exception(msg + ":\n" + fCuRewrite.getCu().getSource().substring(start, start + length))); //$NON-NLS-1$ fResult.addError(msg, JavaStatusContext.create(fCuRewrite.getCu(), fNode)); } @Override
@Override public void updateNode() throws JavaModelException { int start= fNode.getStartPosition(); int length= fNode.getLength(); String msg= "Cannot update found node: nodeType=" + fNode.getNodeType() + "; " //$NON-NLS-1$//$NON-NLS-2$ + fNode.toString() + "[" + start + ", " + length + "] in " + fCuRewrite.getCu(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ JavaPlugin.log(new Exception(msg + ":\n" + fCuRewrite.getCu().getSource().substring(start, start + length))); //$NON-NLS-1$ fResult.addError(msg, JavaStatusContext.create(fCuRewrite.getCu(), fNode)); } @Override
public void updateNode() throws JavaModelException { int start= fNode.getStartPosition(); int length= fNode.getLength(); String msg= "Cannot update found node: nodeType=" + fNode.getNodeType() + "; " //$NON-NLS-1$//$NON-NLS-2$ + fNode.toString() + "[" + start + ", " + length + "] in " + fCuRewrite.getCu(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ JavaPlugin.log(new Exception(msg + ":\n" + fCuRewrite.getCu().getSource().substring(start, start + length))); //$NON-NLS-1$ fResult.addError(msg, JavaStatusContext.create(fCuRewrite.getCu(), fNode)); } protected ListRewrite getParamgumentsRewrite() {