use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addThrowStmt.
public void addThrowStmt(DiagnosticPos poc, Set<Whitespace> ws) {
ExpressionNode throwExpr = this.exprNodeStack.pop();
BLangThrow throwNode = (BLangThrow) TreeBuilder.createThrowNode();
throwNode.pos = poc;
throwNode.addWS(ws);
throwNode.expr = (BLangExpression) throwExpr;
addStmtToCurrentBlock(throwNode);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addExpressionStmt.
public void addExpressionStmt(DiagnosticPos pos, Set<Whitespace> ws) {
BLangExpressionStmt exprStmt = (BLangExpressionStmt) TreeBuilder.createExpressionStatementNode();
exprStmt.pos = pos;
exprStmt.addWS(ws);
exprStmt.expr = (BLangExpression) exprNodeStack.pop();
addStmtToCurrentBlock(exprStmt);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangParserListener method exitSimpleLiteral.
/**
* {@inheritDoc}
*/
@Override
public void exitSimpleLiteral(BallerinaParser.SimpleLiteralContext ctx) {
if (ctx.exception != null) {
return;
}
TerminalNode node;
DiagnosticPos pos = getCurrentPos(ctx);
Set<Whitespace> ws = getWS(ctx);
Long longObject;
BallerinaParser.IntegerLiteralContext integerLiteralContext = ctx.integerLiteral();
if (integerLiteralContext != null && (longObject = getIntegerLiteral(ctx, ctx.integerLiteral())) != null) {
this.pkgBuilder.addLiteralValue(pos, ws, TypeTags.INT, longObject);
} else if ((node = ctx.FloatingPointLiteral()) != null) {
this.pkgBuilder.addLiteralValue(pos, ws, TypeTags.FLOAT, Double.parseDouble(getNodeValue(ctx, node)));
} else if ((node = ctx.BooleanLiteral()) != null) {
this.pkgBuilder.addLiteralValue(pos, ws, TypeTags.BOOLEAN, Boolean.parseBoolean(node.getText()));
} else if ((node = ctx.QuotedStringLiteral()) != null) {
String text = node.getText();
text = text.substring(1, text.length() - 1);
text = StringEscapeUtils.unescapeJava(text);
this.pkgBuilder.addLiteralValue(pos, ws, TypeTags.STRING, text);
} else if (ctx.NullLiteral() != null) {
this.pkgBuilder.addLiteralValue(pos, ws, TypeTags.NULL, null);
}
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangParserListener method getCurrentPos.
private DiagnosticPos getCurrentPos(ParserRuleContext ctx) {
int startLine = ctx.getStart().getLine();
int startCol = ctx.getStart().getCharPositionInLine() + 1;
int endLine = -1;
int endCol = -1;
Token stop = ctx.getStop();
if (stop != null) {
endLine = stop.getLine();
endCol = stop.getCharPositionInLine() + 1;
}
return new DiagnosticPos(diagnosticSrc, startLine, endLine, startCol, endCol);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BLangParserListener method exitObjectFieldDefinition.
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitObjectFieldDefinition(BallerinaParser.ObjectFieldDefinitionContext ctx) {
if (ctx.exception != null) {
return;
}
DiagnosticPos currentPos = getCurrentPos(ctx);
Set<Whitespace> ws = getWS(ctx);
String name = ctx.Identifier().getText();
boolean exprAvailable = ctx.expression() != null;
if (ctx.parent instanceof BallerinaParser.PublicObjectFieldsContext) {
this.pkgBuilder.addFieldToObject(currentPos, ws, name, exprAvailable, 0, false);
} else if (ctx.parent instanceof BallerinaParser.PrivateObjectFieldsContext) {
this.pkgBuilder.addFieldToObject(currentPos, ws, name, exprAvailable, 0, true);
}
}
Aggregations