private String getChildTextFromSource(GroovySourceAST child) { return sourceBuffer.getSnippet( new LineColumn(child.getLine(), child.getColumn()), new LineColumn(child.getLineLast(), child.getColumnLast())); }
protected void printNewlineAndIndent(GroovySourceAST t, int visit) { int currentLine = t.getLine(); if (lastLinePrinted == 0) { lastLinePrinted = currentLine; } if (lastLinePrinted != currentLine) { if (newLines) { if (!(visit == OPENING_VISIT && t.getType() == GroovyTokenTypes.SLIST)) { for (int i=lastLinePrinted;i<currentLine;i++) { out.println(); } if (lastLinePrinted > currentLine) { out.println(); lastLinePrinted = currentLine; } if (visit == OPENING_VISIT || (visit == CLOSING_VISIT && lastLinePrinted > currentLine)) { for (int i=0;i<tabLevel;i++) { out.print(" "); } } } } lastLinePrinted = Math.max(currentLine,lastLinePrinted); } }
public void visitDefault(GroovySourceAST t,int visit) { if (visit == OPENING_VISIT ) { System.out.println("[" + tokenNames[t.getType()] + "]"); int line = t.getLine(); int column = t.getColumn(); int lineLast = t.getLineLast(); int columnLast = t.getColumnLast(); System.out.println("" + line + " / " + column + " - " + lineLast + " / " + columnLast); if (line > 0 && column > 0 && lineLast > 0 && columnLast > 0) { System.out.println("" + sourceBuffer.getSnippet(new LineColumn(line, column), new LineColumn(lineLast, columnLast))); } else { System.out.println("ZERO"); } } else if (visit == CLOSING_VISIT) { System.out.println(); } } }
private String getJavaDocCommentsBeforeNode(GroovySourceAST t) { String result = ""; LineColumn thisLineCol = new LineColumn(t.getLine(), t.getColumn()); String text = sourceBuffer.getSnippet(lastLineCol, thisLineCol); if (text != null) { Matcher m = PREV_JAVADOC_COMMENT_PATTERN.matcher(text); if (m.find()) { result = m.group(1); } } if (isMajorType(t)) { lastLineCol = thisLineCol; } return result; }
private String getName(GroovySourceAST t) { String name = tokenNames[t.getType()] + " <" + t.getType() + ">"; if (!(escape(tokenNames[t.getType()]).equals(escape(t.getText())))) { name = name + " : " + t.getText(); } switch (t.getType()) { case GroovyTokenTypes.METHOD_DEF : case GroovyTokenTypes.VARIABLE_DEF : GroovySourceAST identNode = t.childOfType(GroovyTokenTypes.IDENT); if (identNode != null) { name = name + " : " + identNode.getText() + ""; } } name = escape(name); if (sourceBuffer != null) { name += "
"; name += t.getLine() + "," + t.getColumn() + " - " + t.getLineLast() + "," + t.getColumnLast(); name += "
"; name += escape(sourceBuffer.getSnippet(new LineColumn(t.getLine(), t.getColumn()), new LineColumn(t.getLineLast(), t.getColumnLast()))); } return name; }
private void gobbleComments(GroovySourceAST t, int visit) { if (visit == OPENING_VISIT) { SimpleGroovyClassDoc currentClassDoc = getCurrentClassDoc(); if (currentClassDoc == null || currentClassDoc.isScript()) { if (t.getLine() > lastLineCol.getLine() || (t.getLine() == lastLineCol.getLine() && t.getColumn() > lastLineCol.getColumn())) { getJavaDocCommentsBeforeNode(t); // not normally set for non-major types but appropriate for a script lastLineCol = new LineColumn(t.getLine(), t.getColumn()); } } } }
private String getChildTextFromSource(GroovySourceAST child) { return sourceBuffer.getSnippet( new LineColumn(child.getLine(), child.getColumn()), new LineColumn(child.getLineLast(), child.getColumnLast())); }
public int compareTo(Object object) { if (object == null) { return 0; } if (!(object instanceof AST)) { return 0; } AST that = (AST) object; // todo - possibly check for line/col with values of 0 or less... if (this.getLine() < that.getLine()) { return -1; } if (this.getLine() > that.getLine()) { return 1; } if (this.getColumn() < that.getColumn()) { return -1; } if (this.getColumn() > that.getColumn()) { return 1; } return 0; }
private String getChildTextFromSource(GroovySourceAST child) { return sourceBuffer.getSnippet( new LineColumn(child.getLine(), child.getColumn()), new LineColumn(child.getLineLast(), child.getColumnLast())); }
private String getChildTextFromSource(GroovySourceAST child) { return sourceBuffer.getSnippet( new LineColumn(child.getLine(), child.getColumn()), new LineColumn(child.getLineLast(), child.getColumnLast())); }
private String getChildTextFromSource(GroovySourceAST child) { return sourceBuffer.getSnippet( new LineColumn(child.getLine(), child.getColumn()), new LineColumn(child.getLineLast(), child.getColumnLast())); }
private String getJavaDocCommentsBeforeNode(GroovySourceAST t) { String result = ""; LineColumn thisLineCol = new LineColumn(t.getLine(), t.getColumn()); String text = sourceBuffer.getSnippet(lastLineCol, thisLineCol); if (text != null) { Matcher m = PREV_JAVADOC_COMMENT_PATTERN.matcher(text); if (m.find()) { result = m.group(1); } } if (isMajorType(t)) { lastLineCol = thisLineCol; } return result; }
private void gobbleComments(GroovySourceAST t, int visit) { if (visit == OPENING_VISIT) { SimpleGroovyClassDoc currentClassDoc = getCurrentClassDoc(); if (currentClassDoc == null || currentClassDoc.isScript()) { if (t.getLine() > lastLineCol.getLine() || (t.getLine() == lastLineCol.getLine() && t.getColumn() > lastLineCol.getColumn())) { getJavaDocCommentsBeforeNode(t); // not normally set for non-major types but appropriate for a script lastLineCol = new LineColumn(t.getLine(), t.getColumn()); } } } }
private void gobbleComments(GroovySourceAST t, int visit) { if (visit == OPENING_VISIT) { SimpleGroovyClassDoc currentClassDoc = getCurrentClassDoc(); if (currentClassDoc == null || currentClassDoc.isScript()) { if (t.getLine() > lastLineCol.getLine() || (t.getLine() == lastLineCol.getLine() && t.getColumn() > lastLineCol.getColumn())) { getJavaDocCommentsBeforeNode(t); // not normally set for non-major types but appropriate for a script lastLineCol = new LineColumn(t.getLine(), t.getColumn()); } } } }