private void setVariableScopeEnd(LocalVariableInfo localVarInfo, BLangVariable varNode) { if ((varNode.parent == null) && (varNode.pos != null)) { localVarInfo.scopeEndLineNumber = varNode.pos.eLine; return; } BLangNode parentNode = varNode; while ((parentNode.parent != null)) { parentNode = parentNode.parent; if ((parentNode.getKind().equals(NodeKind.BLOCK)) && (parentNode.parent != null) && (parentNode.parent.pos != null)) { localVarInfo.scopeEndLineNumber = parentNode.parent.pos.eLine; break; } } } }
private void visitFunction(BLangFunction funcNode) { SymbolEnv invokableEnv = SymbolEnv.createFunctionEnv(funcNode, funcNode.symbol.scope, env); this.returnWithintransactionCheckStack.push(true); this.doneWithintransactionCheckStack.push(true); this.returnTypes.push(new HashSet<>()); this.resetFunction(); if (Symbols.isNative(funcNode.symbol)) { return; } boolean isNilableReturn = funcNode.symbol.type.getReturnType().isNullable(); if (isPublicInvokableNode(funcNode)) { analyzeNode(funcNode.returnTypeNode, invokableEnv); } /* the body can be null in the case of Object type function declarations */ if (funcNode.body != null) { analyzeNode(funcNode.body, invokableEnv); // If the return signature is nil-able, an implicit return will be added in Desugar. // Hence this only checks for non-nil-able return signatures and uncertain return in the body. if (!isNilableReturn && !this.statementReturns) { this.dlog.error(funcNode.pos, DiagnosticCode.INVOKABLE_MUST_RETURN, funcNode.getKind().toString().toLowerCase()); } } this.returnTypes.pop(); this.returnWithintransactionCheckStack.pop(); this.doneWithintransactionCheckStack.pop(); }
private static BType getMessageBType(BLangExpression attributeValue) { BType requestType = null; if (NodeKind.SIMPLE_VARIABLE_REF.equals(attributeValue.getKind())) { requestType = ((BLangSimpleVarRef) attributeValue).symbol.getType(); } else if (NodeKind.TYPEDESC_EXPRESSION.equals(attributeValue.getKind())) { requestType = ((BLangTypedescExpr) attributeValue).resolvedType; } return requestType; }
public void visit(BLangSimpleVariable varNode) { analyzeExpr(varNode.expr); if (Objects.isNull(varNode.symbol)) { return; } if (!Symbols.isPublic(varNode.symbol)) { if (varNode.expr == null && Symbols.isFlagOn(varNode.symbol.flags, Flags.LISTENER)) { dlog.error(varNode.pos, DiagnosticCode.UNINITIALIZED_VARIABLE, varNode.name); } return; } int ownerSymTag = this.env.scope.owner.tag; if (((ownerSymTag & SymTag.INVOKABLE) != SymTag.INVOKABLE) || (varNode.type != null && varNode.parent != null && NodeKind.FUNCTION.equals(varNode.parent.getKind()))) { analyseType(varNode.type, varNode.pos); } if (varNode.expr == null && ownerSymTag == SymTag.PACKAGE) { this.dlog.error(varNode.pos, DiagnosticCode.UNINITIALIZED_VARIABLE, varNode.name); } }
boolean isSnippet = context.get(CompletionKeys.CLIENT_CAPABILITIES_KEY).getCompletionItem().getSnippetSupport(); if (!objectNode.getKind().equals(NodeKind.OBJECT_TYPE)) { return completionItems;
BType bType = null; if (!symbolEnvNode.getKind().equals(NodeKind.MATCH_EXPRESSION)) { return completionItems;
BLangNode node, BSymbol bSymbol) { Node recordNode = treeVisitor.getBlockOwnerStack().peek(); if (!recordNode.getKind().equals(NodeKind.RECORD_TYPE)) { return false;