public String getQualifiedPackageName() { String orgName = this.orgName.toString(); String pkgName = String.join(".", pkgNameComps.stream() .map(id -> id.value) .collect(Collectors.toList())); String versionStr = (this.version.value != null) ? this.version.value : ""; if (!versionStr.isEmpty()) { versionStr = " version " + versionStr; } String aliasStr = (this.version.value != null) ? this.version.value : ""; if (!aliasStr.isEmpty()) { aliasStr = " as " + aliasStr; } return (orgName.isEmpty() ? "" : orgName + '/') + pkgName + versionStr + aliasStr; } }
/** * This method will determine if the type guard of the preceding pattern will result in the current pattern * being unreachable. * * @param precedingGuard type guard of the preceding structured pattern * @param currentGuard type guard of the cuurent structured pattern * @return true if the current pattern is unreachable due to the type guard of the preceding pattern */ private boolean checkTypeGuardSimilarity(BLangExpression precedingGuard, BLangExpression currentGuard) { // check if type guard is a type test expr and compare the variable ref and type node if (precedingGuard != null && currentGuard != null) { if (precedingGuard.getKind() == NodeKind.TYPE_TEST_EXPR && currentGuard.getKind() == NodeKind.TYPE_TEST_EXPR && ((BLangTypeTestExpr) precedingGuard).expr.getKind() == NodeKind.SIMPLE_VARIABLE_REF && ((BLangTypeTestExpr) currentGuard).expr.getKind() == NodeKind.SIMPLE_VARIABLE_REF) { BLangTypeTestExpr precedingTypeTest = (BLangTypeTestExpr) precedingGuard; BLangTypeTestExpr currentTypeTest = (BLangTypeTestExpr) currentGuard; return ((BLangSimpleVarRef) precedingTypeTest.expr).variableName.toString().equals( ((BLangSimpleVarRef) currentTypeTest.expr).variableName.toString()) && precedingTypeTest.typeNode.type.tag == currentTypeTest.typeNode.type.tag; } return false; } return currentGuard != null || precedingGuard == null; }
List<CompletionItem> completionItems = CommonUtil.getCurrentFileImports(srcOwnerPkg, ctx).stream() .map(bLangImportPackage -> { String orgName = bLangImportPackage.orgName.toString(); String pkgName = String.join(".", bLangImportPackage.pkgNameComps.stream() .map(id -> id.value)
BLangRecordLiteral.BLangRecordKeyValue bRefType = valueFrom.getKeyValuePairs().get(0); BLangSimpleVarRef refType = (BLangSimpleVarRef) bRefType.getKey(); switch (refType.variableName.toString()) { case "fieldRef": BLangRecordLiteral.BLangRecordKeyValue fieldRefValue =