use of org.codehaus.groovy.antlr.LineColumn in project groovy by apache.
the class MindMapPrinter method getName.
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;
}
use of org.codehaus.groovy.antlr.LineColumn in project groovy by apache.
the class LineColumnChecker method visitDefault.
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();
}
}
use of org.codehaus.groovy.antlr.LineColumn in project groovy by apache.
the class SimpleGroovyClassDocAssembler method gobbleComments.
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());
}
}
}
}
use of org.codehaus.groovy.antlr.LineColumn in project groovy by apache.
the class SimpleGroovyClassDocAssembler method getJavaDocCommentsBeforeNode.
// todo - If no comment before node, then get comment from same node on parent class - ouch!
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;
}
use of org.codehaus.groovy.antlr.LineColumn in project gradle by gradle.
the class SourceMetaDataVisitor method getJavaDocCommentsBeforeNode.
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);
}
}
lastLineCol = thisLineCol;
return result;
}
Aggregations