use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class AssignmentStmtContextSorter method getVariableType.
/**
* Get the variable type.
*
* @param ctx Document Service context (Completion context)
* @return {@link String} type of the variable
*/
@Override
String getVariableType(TextDocumentServiceContext ctx) {
String variableName = ctx.get(DocumentServiceKeys.PARSER_RULE_CONTEXT_KEY).getStart().getText();
List<SymbolInfo> visibleSymbols = ctx.get(CompletionKeys.VISIBLE_SYMBOLS_KEY);
SymbolInfo filteredSymbol = visibleSymbols.stream().filter(symbolInfo -> {
BSymbol bSymbol = symbolInfo.getScopeEntry().symbol;
String symbolName = symbolInfo.getSymbolName();
return bSymbol instanceof BVarSymbol && symbolName.equals(variableName);
}).findFirst().orElse(null);
if (filteredSymbol != null) {
return filteredSymbol.getScopeEntry().symbol.type.toString();
}
return "";
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class SymbolEnter method visit.
@Override
public void visit(BLangStruct structNode) {
BSymbol structSymbol = Symbols.createStructSymbol(Flags.asMask(structNode.flagSet), names.fromIdNode(structNode.name), env.enclPkg.symbol.pkgID, null, env.scope.owner);
structNode.symbol = structSymbol;
// Create struct type
structNode.symbol.type = new BStructType((BTypeSymbol) structNode.symbol);
defineSymbol(structNode.pos, structSymbol);
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class SymbolEnter method visit.
public void visit(BLangAnnotation annotationNode) {
BSymbol annotationSymbol = Symbols.createAnnotationSymbol(Flags.asMask(annotationNode.flagSet), names.fromIdNode(annotationNode.name), env.enclPkg.symbol.pkgID, null, env.scope.owner);
annotationSymbol.type = new BAnnotationType((BAnnotationSymbol) annotationSymbol);
annotationNode.attachmentPoints.forEach(point -> ((BAnnotationSymbol) annotationSymbol).attachmentPoints.add(point));
annotationNode.symbol = annotationSymbol;
defineSymbol(annotationNode.pos, annotationSymbol);
SymbolEnv annotationEnv = SymbolEnv.createAnnotationEnv(annotationNode, annotationSymbol.scope, env);
annotationNode.attributes.forEach(att -> this.defineNode(att, annotationEnv));
if (annotationNode.typeNode != null) {
BType structType = this.symResolver.resolveTypeNode(annotationNode.typeNode, annotationEnv);
((BAnnotationSymbol) annotationSymbol).attachedType = structType.tsymbol;
}
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class SymbolEnter method visit.
@Override
public void visit(BLangObject objectNode) {
BSymbol objectSymbol = Symbols.createObjectSymbol(Flags.asMask(objectNode.flagSet), names.fromIdNode(objectNode.name), env.enclPkg.symbol.pkgID, null, env.scope.owner);
objectNode.symbol = objectSymbol;
// Create struct type
objectNode.symbol.type = new BStructType((BTypeSymbol) objectNode.symbol);
defineSymbol(objectNode.pos, objectSymbol);
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class SymbolResolver method resolveObject.
public BSymbol resolveObject(DiagnosticPos pos, DiagnosticCode code, SymbolEnv env, Name pkgAlias, Name objectName) {
BSymbol pkgSymbol = resolvePkgSymbol(pos, env, pkgAlias);
if (pkgSymbol == symTable.notFoundSymbol) {
return pkgSymbol;
}
BSymbol symbol = lookupMemberSymbol(pos, pkgSymbol.scope, env, objectName, SymTag.OBJECT);
if (symbol == symTable.notFoundSymbol) {
dlog.error(pos, code, objectName);
}
return symbol;
}
Aggregations