Search in sources :

Example 1 with JooSymbol

use of net.jangaroo.jooc.JooSymbol in project jangaroo-tools by CoreMedia.

the class SemicolonTerminatedStatement method analyze.

public void analyze(AstNode parentNode) {
    // check for special case "assert statement":
    if (getOptStatement() instanceof ApplyExpr && getOptSymSemicolon() != null) {
        ApplyExpr applyExpr = (ApplyExpr) getOptStatement();
        JooSymbol funSymbol = applyExpr.getFun().getSymbol();
        String functionName = funSymbol.getText();
        if ("trace".equals(functionName) || SyntacticKeywords.ASSERT.equals(functionName)) {
            compilationUnit.addBuiltInUsage(functionName);
        }
    }
    super.analyze(parentNode);
    if (getOptStatement() != null) {
        getOptStatement().analyze(this);
    }
}
Also used : JooSymbol(net.jangaroo.jooc.JooSymbol)

Example 2 with JooSymbol

use of net.jangaroo.jooc.JooSymbol in project jangaroo-tools by CoreMedia.

the class JsCodeGenerator method writeMemberAccess.

private void writeMemberAccess(IdeDeclaration memberDeclaration, JooSymbol optSymDot, Ide memberIde, boolean writeMemberWhitespace) throws IOException {
    if (memberDeclaration != null) {
        if (memberIde.usePrivateMemberName(memberDeclaration)) {
            writePrivateMemberAccess(optSymDot, memberIde, writeMemberWhitespace, memberDeclaration.isStatic());
            return;
        }
    }
    if (optSymDot == null && memberDeclaration != null && !memberDeclaration.isConstructor()) {
        optSymDot = new JooSymbol(".");
    }
    boolean quote = false;
    if (optSymDot != null) {
        if (memberIde.getIde().getText().startsWith("@")) {
            quote = true;
            out.writeSymbolWhitespace(optSymDot);
            out.writeToken("['");
        } else {
            out.writeSymbol(optSymDot);
        }
    }
    out.writeSymbol(memberIde.getIde(), writeMemberWhitespace);
    if (quote) {
        out.writeToken("']");
    }
}
Also used : JooSymbol(net.jangaroo.jooc.JooSymbol)

Example 3 with JooSymbol

use of net.jangaroo.jooc.JooSymbol in project jangaroo-tools by CoreMedia.

the class ConfigClassBuilder method parseDescription.

public static String parseDescription(JooSymbol symbol, JooSymbol[] symModifiers) {
    JooSymbol firstSymbol = symbol;
    if (symModifiers.length > 0) {
        firstSymbol = symModifiers[0];
    }
    String whitespace = firstSymbol.getWhitespace();
    int pos = 0;
    String lastAsDocComment = null;
    while (true) {
        int commentStart = whitespace.indexOf(COMMENT_START, pos);
        int lineCommentStart = whitespace.indexOf(LINE_COMMENT_START, pos);
        if (commentStart < 0) {
            break;
        }
        if (lineCommentStart >= 0 && lineCommentStart < commentStart) {
            pos = findLineCommentEnd(whitespace, lineCommentStart) + 1;
        } else {
            int endPos = findCommentEndPos(whitespace, commentStart);
            if (whitespace.substring(commentStart).startsWith(ASDOC_COMMENT_START)) {
                String comment = whitespace.substring(commentStart + ASDOC_COMMENT_START.length(), endPos);
                lastAsDocComment = parseAsDocComment(comment);
            }
            pos = endPos + COMMENT_END.length();
        }
    }
    return lastAsDocComment;
}
Also used : JooSymbol(net.jangaroo.jooc.JooSymbol)

Example 4 with JooSymbol

use of net.jangaroo.jooc.JooSymbol in project jangaroo-tools by CoreMedia.

the class JsCodeGenerator method getFunctionNameAsIde.

public String getFunctionNameAsIde(FunctionExpr functionExpr) {
    IdeDeclaration classDeclaration = functionExpr.getClassDeclaration();
    String classNameAsIde = "";
    if (classDeclaration != null) {
        classNameAsIde = out.getQualifiedNameAsIde(classDeclaration);
    }
    JooSymbol sym = functionExpr.getSymbol();
    return classNameAsIde + "$" + sym.getLine() + "_" + sym.getColumn();
}
Also used : IdeDeclaration(net.jangaroo.jooc.ast.IdeDeclaration) TypedIdeDeclaration(net.jangaroo.jooc.ast.TypedIdeDeclaration) JooSymbol(net.jangaroo.jooc.JooSymbol)

Example 5 with JooSymbol

use of net.jangaroo.jooc.JooSymbol in project jangaroo-tools by CoreMedia.

the class JsCodeGenerator method visitApplyExpr.

@Override
public void visitApplyExpr(ApplyExpr applyExpr) throws IOException {
    generateFunJsCode(applyExpr);
    if (applyExpr.getArgs() != null) {
        boolean isAssert = applyExpr.getFun() instanceof IdeExpr && SyntacticKeywords.ASSERT.equals(applyExpr.getFun().getSymbol().getText());
        if (isAssert) {
            JooSymbol symKeyword = applyExpr.getFun().getSymbol();
            out.writeSymbol(applyExpr.getArgs().getLParen());
            applyExpr.getArgs().getExpr().visit(this);
            out.writeToken(", ");
            out.writeString(new File(symKeyword.getFileName()).getName());
            out.writeToken(", ");
            out.writeInt(symKeyword.getLine());
            out.write(", ");
            out.writeInt(symKeyword.getColumn());
            out.writeSymbol(applyExpr.getArgs().getRParen());
        } else {
            applyExpr.getArgs().visit(this);
        }
    }
}
Also used : IdeExpr(net.jangaroo.jooc.ast.IdeExpr) File(java.io.File) JooSymbol(net.jangaroo.jooc.JooSymbol)

Aggregations

JooSymbol (net.jangaroo.jooc.JooSymbol)7 File (java.io.File)1 CompilerError (net.jangaroo.jooc.CompilerError)1 Catch (net.jangaroo.jooc.ast.Catch)1 Ide (net.jangaroo.jooc.ast.Ide)1 IdeDeclaration (net.jangaroo.jooc.ast.IdeDeclaration)1 IdeExpr (net.jangaroo.jooc.ast.IdeExpr)1 NamespacedIde (net.jangaroo.jooc.ast.NamespacedIde)1 QualifiedIde (net.jangaroo.jooc.ast.QualifiedIde)1 TypeRelation (net.jangaroo.jooc.ast.TypeRelation)1 TypedIdeDeclaration (net.jangaroo.jooc.ast.TypedIdeDeclaration)1