Search in sources :

Example 6 with LineColumn

use of org.codehaus.groovy.antlr.LineColumn in project groovy-core by groovy.

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 += "&#xa;";
        name += t.getLine() + "," + t.getColumn() + " - " + t.getLineLast() + "," + t.getColumnLast();
        name += "&#xa;";
        name += escape(sourceBuffer.getSnippet(new LineColumn(t.getLine(), t.getColumn()), new LineColumn(t.getLineLast(), t.getColumnLast())));
    }
    return name;
}
Also used : GroovySourceAST(org.codehaus.groovy.antlr.GroovySourceAST) LineColumn(org.codehaus.groovy.antlr.LineColumn)

Example 7 with LineColumn

use of org.codehaus.groovy.antlr.LineColumn in project groovy-core by groovy.

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());
            }
        }
    }
}
Also used : LineColumn(org.codehaus.groovy.antlr.LineColumn)

Example 8 with LineColumn

use of org.codehaus.groovy.antlr.LineColumn in project groovy-core by groovy.

the class SimpleGroovyClassDocAssembler method getChildTextFromSource.

private String getChildTextFromSource(GroovySourceAST child, String tokens) {
    String text = sourceBuffer.getSnippet(new LineColumn(child.getLine(), child.getColumn()), new LineColumn(child.getLine() + 1, 0));
    StringTokenizer st = new StringTokenizer(text, tokens);
    return st.nextToken();
}
Also used : LineColumn(org.codehaus.groovy.antlr.LineColumn)

Example 9 with LineColumn

use of org.codehaus.groovy.antlr.LineColumn in project groovy-core by groovy.

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;
}
Also used : LineColumn(org.codehaus.groovy.antlr.LineColumn) Matcher(java.util.regex.Matcher)

Example 10 with LineColumn

use of org.codehaus.groovy.antlr.LineColumn in project groovy by apache.

the class SimpleGroovyClassDocAssembler method getChildTextFromSource.

private String getChildTextFromSource(GroovySourceAST child, String tokens) {
    String text = sourceBuffer.getSnippet(new LineColumn(child.getLine(), child.getColumn()), new LineColumn(child.getLine() + 1, 0));
    StringTokenizer st = new StringTokenizer(text, tokens);
    return st.nextToken();
}
Also used : LineColumn(org.codehaus.groovy.antlr.LineColumn)

Aggregations

LineColumn (org.codehaus.groovy.antlr.LineColumn)11 Matcher (java.util.regex.Matcher)3 GroovySourceAST (org.codehaus.groovy.antlr.GroovySourceAST)2